<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2020/8/21
 * Time: 17:01
 */

namespace app\common\lib\astrolog;

/**
 * Class SynastryData
 * @package app\common\lib\astrolog
 */
class SynastryData
{
    // 每颗星设定合盘计分比重值如下太阳80，月亮110，水星50，金星60，火星50，上升80，中天70；共500
    private $base = [0 => 80, 1 => 110, 2 => 50, 3 => 60, 4 => 50, ASC => 80, MC => 70];
    private $sex1;
    private $sex2;
    private $timestamp1;
    private $timestamp2;
    protected $type = 1;// 合盘类型 1=>普通合盘 2=>明星合盘 5=>名人合盘

    public function __construct()
    {
    }

    /**
     * 设置合盘模式
     * @param int $type  1=>普通合盘 2=>明星合盘 5=>名人合盘
     * @return $this
     */
    public function setSynastryType($type = 1)
    {
        $this->type = $type;
        return $this;
    }

    /**
     * 获取合盘数据
     * @param array $options
     * 'recode1' => array
     * 'recode2' => array
     * @return array
     */
    public function getScore($options = [])
    {
        $settting1 = [
            'synastry' => [
                'asp_orb_all' => [0 => 6, 60 => 4, 90 => 6, 120 => 6, 180 => 6, 30 => 1, 150 => 2, 45 => 2, 135 => 2, 72 => 2, 144 => 2],
                'asps_display' => [0, 60, 90, 120, 180],
                'planets_display' => '111111111100100001001',
                'planet_orb_all' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                'h_sys' => 'p',
            ],
        ];

        $Astrolog = Astrolog::getInstance()
            ->setExecPrefix(config('astrolog.prefix'))
            ->setUserSetting($settting1)
            ->setIsAstrolabe(true)
            ->setGetDatas(['synastry']);

        $synastry1 = $Astrolog
            ->setRecode1($options['recode1'])
            ->setRecode2($options['recode2'])
            ->getAstroDatas()
            ->getDatas('synastry');

        $nowTime = time();
        // 2020-08-26 00:00:00
        if ($nowTime > 1598371200)
        {
            // 出生时间转换为时间戳
            $this->timestamp1 = $Astrolog->getRecode1()['ut_timestamp'];
            // 出生时间转换为时间戳
            $this->timestamp2 = $Astrolog->getRecode2()['ut_timestamp'];
        }

        $synastry2 = $Astrolog
            ->setRecode1($options['recode2'])
            ->setRecode2($options['recode1'])
            ->getAstroDatas()
            ->getDatas('synastry');

        $synastry1[0]['planets'] = (array)$synastry1[0]['planets'];
        $synastry1[1]['planets'] = (array)$synastry1[1]['planets'];
        $synastry2[0]['planets'] = (array)$synastry2[0]['planets'];
        $synastry2[1]['planets'] = (array)$synastry2[1]['planets'];

        $astro1 = ['details1' => $synastry1[0], 'details2' => $synastry1[1]];
        $astro2 = ['details1' => $synastry2[0], 'details2' => $synastry2[1]];

        if ($nowTime > 1598371200)
        {
            $this->sex1 = $options['recode1']['type'];
            $this->sex2 = $options['recode2']['type'];
        }

        $attract = $this->getTheAttractScore($astro1, $astro2);// 吸引指数
        $chat = $this->getTheChatScore($astro1, $astro2);// 沟通指数
        $passion = $this->getThePassionScore($astro1, $astro2);// 激情指数
        $benefit = $this->getTheintimateScore($astro1, $astro2);// 亲密指数
        $happy = $this->getTheHappyScore($astro1, $astro2);// 愉悦指数
        $probTobeLover = $this->getTheProbTobeLover($astro1, $astro2);// 缘分指数
        $attract = ($attract / 200 * 100);
        $chat = ($chat / 120 * 100);
        $passion = ($passion / 180 * 100);
        $benefit = ($benefit / 120 * 100);
        $happy = ($happy / 130 * 100);
        $probTobeLover = ($probTobeLover / 180 * 100);
        $attract = $attract > 100 ? 100 : ($attract < 1 ? 1 : round($attract));
        $chat = $chat > 100 ? 100 : ($chat < 1 ? 1 : round($chat));
        $passion = $passion > 100 ? 100 : ($passion < 1 ? 1 : round($passion));
        $benefit = $benefit > 100 ? 100 : ($benefit < 1 ? 1 : round($benefit));
        $happy = $happy > 100 ? 100 : ($happy < 1 ? 1 : round($happy));
        $probTobeLover = $probTobeLover > 100 ? 100 : ($probTobeLover < 1 ? 1 : round($probTobeLover));
        $relation = $this->getTheRelation($astro1, $astro2, $attract, $chat, $passion, $benefit, $happy, $probTobeLover);
        $relationCount = count($relation);
        for ($i = 0; $i < $relationCount; $i++)
        {
            if ($relation[$i]['per'] <= 0) $relation[$i]['per'] = 0.01;

            elseif ($relation[$i]['per'] >= 1) $relation[$i]['per'] = 0.99;
        }
        // 重新索引
        $relation = resort($relation, 'per');

        if ($options['type'] !== 0)
        {
            $harmoniousAndConflict = $this->getTheHarmoniousAndConflict($astro1, $astro2);

            if ($attract < 20) $attract_text = '疏离淡漠';
            elseif ($attract < 40) $attract_text = '落花无情';
            elseif ($attract < 60) $attract_text = '怦然心动';
            elseif ($attract < 80) $attract_text = '念念不忘';
            else $attract_text = '魂牵梦绕';
            if ($chat < 20) $chat_text = '鸡同鸭讲';
            elseif ($chat < 40) $chat_text = '话不投机';
            elseif ($chat < 60) $chat_text = '交流顺畅';
            elseif ($chat < 80) $chat_text = '相谈甚欢';
            else $chat_text = '无话不谈';
            if ($happy < 20) $happy_text = '毫无乐趣';
            elseif ($happy < 40) $happy_text = '略显乏味';
            elseif ($happy < 60) $happy_text = '眉开眼笑';
            elseif ($happy < 80) $happy_text = '其乐融融';
            else $happy_text = '欢聚无限';
            if ($passion < 20) $passion_text = '兴趣缺缺';
            elseif ($passion < 40) $passion_text = '激情寥寥';
            elseif ($passion < 60) $passion_text = '火花四射';
            elseif ($passion < 80) $passion_text = '烈焰焚身';
            else $passion_text = '天雷地火';
            if ($benefit < 20) $benefit_text = '心有鸿沟';
            elseif ($benefit < 40) $benefit_text = '若即若离';
            elseif ($benefit < 60) $benefit_text = '一拍即合';
            elseif ($benefit < 80) $benefit_text = '引为知己';
            else $benefit_text = '如胶似漆';
            if ($probTobeLover < 20) $probTobeLover_text = '情淡缘浅';
            elseif ($probTobeLover < 40) $probTobeLover_text = '有缘无分';
            elseif ($probTobeLover < 60) $probTobeLover_text = '缘起缘灭';
            elseif ($probTobeLover < 80) $probTobeLover_text = '前缘深厚';
            else $probTobeLover_text = '不解之缘';

            $others = $this->getFoothold($astro1, $astro2, $attract, $chat, $passion, $benefit, $happy, $probTobeLover, $harmoniousAndConflict, $relation);

            $data = [
                'score' => [
                    'attract' => ['num' => $attract, 'text' => $attract_text],
                    'chat' => ['num' => $chat, 'text' => $chat_text],
                    'passion' => ['num' => $passion, 'text' => $passion_text],
                    'benefit' => ['num' => $benefit, 'text' => $benefit_text],
                    'happy' => ['num' => $happy, 'text' => $happy_text],
                    'probTobeLover' => ['num' => $probTobeLover, 'text' => $probTobeLover_text],
                ],
                'harmoniousAndConflict' => $harmoniousAndConflict,// 和谐冲突
                'relation' => $relation,// 双方可能的关系
                'foothold' => $others['foothold'],// 立足点
                'conflict' => $others['conflict'],// 矛盾点
                'score2' => $others['score1'],// id1 对 id2 即id1当底盘
                'score1' => $others['score2'],// id1 对 id2 即id1当底盘
                'if_love' => $others['if_love'],
                'if_love_status' => $others['if_love_status'],
            ];
        } else
        {
            $data = [
                'scoreNum' => $attract + $chat + $passion + $benefit + $happy + $probTobeLover,
                'relationText' => $relation[0]['name_cn'],// 双方可能的关系
            ];
        }

        return $data;
    }

    /**
     * 获取个人星正反引动指数 日月水金火木土天海冥
     * 木土天海冥北交相位对象只计算日月水金火四轴
     * 有相位系数(使用中)
     * @param $data
     * @return array
     */
    protected function getThePrimingScore($data = [])
    {
        $ret = ['obverse' => [], 'versa' => []];
        $imp_o = [0 => 14, 1 => 15, 2 => 8, 3 => 10, 4 => 9, 5 => 7.5, 6 => 3, 7 => 5, 8 => 5, 9 => 4, 12 => 4, ASC => 14, MC => 13];// 重要指数=》正
        $imp_v = [0 => 14, 1 => 15, 2 => 8, 3 => 10, 4 => 9, 5 => 7.5, 6 => 15, 7 => 5, 8 => 5, 9 => 4, 12 => 4, ASC => 14, MC => 13];// 重要指数=》反
        $b = $data['details2'];// b用户
        $planets = $b['planets'];
        foreach ($planets as $i => $p)
        {
            if ($i > 12 && $i != ASC && $i != MC) continue;
            $ret['obverse'][$i] = $ret['versa'][$i] = 0;

            if (empty($p['phase'])) continue;// 空相时结束本轮循环
            foreach ($p['phase'] as $phase)
            {
                $k = $phase['id'];
                $phase_e = $phase['phase_e'];
                $phase_orb = $phase['phase_orb'];
                $coef_o = 0;// 正面系数
                $coef_v = 0;// 反面系数
                $phase_o = 0;// 相位系数
                if ($phase_orb < 0.5) $phase_o = 1;
                elseif ($phase_orb < 1.5) $phase_o = 0.9;
                elseif ($phase_orb < 3) $phase_o = 0.85;
                elseif ($phase_orb <= 5) $phase_o = 0.8;
                elseif ($phase_orb > 5) $phase_o = 0.75;

                if (in_array($k, [0, 1, 2, 3, 5]))
                {
                    if ($phase_e == 0) $coef_o = 1;
                    elseif ($phase_e == 60) $coef_o = 0.7;
                    elseif ($phase_e == 120) $coef_o = 0.85;
                    elseif ($phase_e == 90)
                    {
                        $coef_o = 0.2;
                        $coef_v = 0.8;
                    } elseif ($phase_e == 180)
                    {
                        $coef_o = 0.7;
                        $coef_v = 0.5;
                    }
                    $ret['obverse'][$i] += $imp_o[$k] * $coef_o * $phase_o;
                    $ret['versa'][$i] += $imp_v[$k] * $coef_v * $phase_o;
                } elseif ($k == 4 || $k == 6)
                {
                    if ($phase_e == 0)
                    {
                        $coef_o = 1;
                        $coef_v = 0.5;
                        if ($k == 4)
                        {
                            $coef_o = 0.5;
                            $coef_v = 0.8;
                        }
                    } elseif ($phase_e == 60)
                    {
                        $coef_o = 0.7;
                        $coef_v = 0.2;
                    } elseif ($phase_e == 90)
                    {
                        $coef_o = 0.2;
                        $coef_v = 0.9;
                    } elseif ($phase_e == 120)
                    {
                        $coef_o = 0.8;
                        $coef_v = 0.2;
                    } elseif ($phase_e == 180)
                    {
                        $coef_o = 0.7;
                        $coef_v = 0.7;
                    }
                    $ret['obverse'][$i] += $imp_o[$k] * $coef_o * $phase_o;
                    if ($k == 6) $ret['versa'][$i] += $imp_v[$k] * $coef_v * $phase_o;
                    else $ret['versa'][$i] += $imp_v[$k] * $coef_v * $phase_o;
                } elseif (in_array($i, [0, 1, 2, 3, 4, ASC, MC]) && in_array($k, [7, 8, 9]))
                {
                    if ($phase_e == 0)
                    {
                        $coef_o = 1;
                        $coef_v = 0.5;
                    } elseif ($phase_e == 60)
                    {
                        $coef_o = 0.7;
                        $coef_v = 0.2;
                    } elseif ($phase_e == 90)
                    {
                        $coef_o = 0.2;
                        $coef_v = 0.9;
                    } elseif ($phase_e == 120)
                    {
                        $coef_o = 0.8;
                        $coef_v = 0.2;
                    } elseif ($phase_e == 180)
                    {
                        $coef_o = 0.7;
                        $coef_v = 0.7;
                    }
                    $ret['obverse'][$i] += $imp_o[$k] * $coef_o * $phase_o;
                    $ret['versa'][$i] += $imp_v[$k] * $coef_v * $phase_o;
                } // 北交点
                elseif (in_array($i, [0, 1, 2, 3, 4, ASC, MC]) && $k == 12)
                {
                    if ($phase_e == 0) $coef_o = 1;
                    elseif ($phase_e == 60) $coef_o = 0.7;
                    elseif ($phase_e == 90) $coef_o = 0.7;
                    elseif ($phase_e == 120) $coef_o = 0.7;
                    elseif ($phase_e == 180) $coef_o = 1;
                    $ret['obverse'][$i] += $imp_o[$k] * $coef_o * $phase_o;

                } elseif ($k == ASC || $k == MC)
                {
                    if ($phase_e == 0) $coef_o = 1;
                    elseif ($phase_e == 60) $coef_o = 0.6;
                    elseif ($phase_e == 90)
                    {
                        $coef_o = 0.2;
                        $coef_v = 0.8;
                    } elseif ($phase_e == 120) $coef_o = 0.65;
                    elseif ($phase_e == 180) $coef_o = 0.9;
                    $ret['obverse'][$i] += $imp_o[$k] * $coef_o * $phase_o;
                    $ret['versa'][$i] += $imp_v[$k] * $coef_v * $phase_o;
                }
            }
        }
        return $ret;
    }

    /**
     * 获取宫位增益能量和破坏能量
     * @param array $data1
     * @param array $data2
     * @return array
     */
    protected function getTheHousePower($data1 = [], $data2 = [])
    {
        $planets1 = $data1['details2']['planets'];
        $planets1_2 = $data1['details1']['planets'];
        $planets2 = $data2['details2']['planets'];
        $planets2_2 = $data2['details1']['planets'];
        $good = [0 => 20, 1 => 20, 2 => 9, 3 => 12, 4 => 10, 5 => 12, 6 => 2, 7 => 2, 8 => 2, 9 => 2, 12 => 3];// 增益能量
        $bad = [4 => 4, 6 => 6, 7 => 1, 8 => 2, 9 => 1];// 破坏能量
        $hg = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0];// 宫位增益能量
        $hb = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0];// 宫位破坏能量
        // 日月水金火木土天海冥
        for ($i = 0; $i < 13; $i++)
        {
            if ($i > 9 && $i < 12) continue;
            if (!isset($planets1[$i])) continue;
            $planet1 = $planets1[$i];// A在B A
            $planet2 = $planets2[$i];// B在A B

            if (!empty($planet1['phase']))
            {
                $phase0_num = 0;
                $first = 8;
                $second = 8;
                $h_f = NULL;
                $h_s = NULL;
                $h = NULL;
                foreach ($planet1['phase'] as $phase)
                {
                    if (!in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, ASC, MC])) continue;
                    if ($phase['id'] == ASC)
                    {
                        // 合上升
                        if ($phase['phase_e'] == 0)
                        {
                            if (isset($good[$i])) $hg[1] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[1] += $bad[$i] + 15;
                        } // 合下降
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (isset($good[$i])) $hg[7] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[7] += $bad[$i] + 15;
                        }
                    } elseif ($phase['id'] == MC)
                    {
                        // 合天顶
                        if ($phase['phase_e'] == 0)
                        {
                            if (isset($good[$i])) $hg[10] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[10] += $bad[$i] + 15;
                        } // 合天底
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (isset($good[$i])) $hg[4] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[4] += $bad[$i] + 15;
                        }
                    } else
                    {
                        // 容许系数
                        $_orb = $phase['phase_orb'];
                        if ($_orb < 0.5) $o = 1;
                        elseif ($_orb < 1.5) $o = 0.9;
                        elseif ($_orb < 3) $o = 0.85;
                        elseif ($_orb <= 5) $o = 0.8;
                        else $o = 0.75;
                        $h = $planet1['in_house_id'];// 外盘星体落在底盘中的宫位
                        $h2 = $planets1_2[$phase['id']]['in_house_id'];// 底盘星体所在宫位
                        // 若与内盘某星成合相，该宫位增益能量或破坏能量+相应的外盘星体基本能量*容许系数
                        // （多颗星则以最紧密的相位计算，再加上次紧密的相位的一半）
                        if ($phase['phase_e'] == 0)
                        {
                            $phase0_num++;
                            if ($phase0_num == 0)
                            {
                                $first = $o;
                                $h_f = $h2;
                            } elseif ($o < $first)
                            {
                                $second = $first;
                                $first = $o;
                                $h_s = $h_f;
                                $h_f = $h2;
                            } elseif ($o > $first && $o < $second)
                            {
                                $second = $o;
                                $h_s = $h2;
                            }
                        }
                        // 若与内盘星体成六分相，检测成相星体所在宫位，该宫位增益能量+相应的外盘星体基本能量*容许系数*0.5（无破坏）
                        // 外盘星体所在宫位的增益能量+成相星体的基本能量*容许系数*0.5
                        elseif ($phase['phase_e'] == 60)
                        {
                            if (isset($good[$i])) $hg[$h2] += $good[$i] * $o * 0.5;
                            if (isset($good[$phase['id']])) $hg[$h] += $good[$phase['id']] * $o * 0.5;
                        }
                        // 若与内盘星体成四分相，分两种情况计算
                        // 1、	若外盘星体为火土天海冥（对双方都是天海冥的相位不予计算），对内盘成相星体宫位造成的破坏为
                        //  外盘星基本破坏能量*容许系数*2
                        // 2、	若外盘星体为日月水金木，对内盘成相星体宫位造成的
                        // 破坏为 外盘星基本增益能量*容许系数*0.3；
                        // 增益为 外盘星基本增益能量*容许系数*0.1
                        // 【对外盘星所在宫位的破坏，也按上述步骤计算】
                        elseif ($phase['phase_e'] == 90)
                        {
                            if (in_array($i, [4, 6, 7, 8, 9]))
                            {
                                if (in_array($i, [7, 8, 9]) && in_array($phase['id'], [7, 8, 9])) continue;
                                if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $o * 2;
                            } elseif (in_array($i, [0, 1, 2, 3, 5]))
                            {
                                if (isset($good[$phase['id']])) $hg[$h2] += $good[$phase['id']] * $o * 0.1;
                                if (isset($good[$phase['id']])) $hb[$h2] += $good[$phase['id']] * $o * 0.3;
                            }
                        }
                        // 若与内盘星体成三分相，检测成相星体所在宫位，该宫位增益能量+相应的外盘星体基本能量*容许系数*0.6（无破坏）
                        // 外盘星体所在宫位的增益能量+成相星体的基本能量*容许系数*0.6
                        elseif ($phase['phase_e'] == 120)
                        {
                            if (isset($good[$i])) $hg[$h2] += $good[$i] * $o * 0.6;
                            if (isset($good[$phase['id']])) $hg[$h] += $good[$phase['id']] * $o * 0.6;
                        }
                        // 若与内盘星体成对分相，分两种情况计算
                        // 1、	若外盘星体为火土天海冥（对双方都是天海冥的相位不予计算），对内盘成相星体宫位造成的破坏为
                        // 外盘星基本破坏能量*容许系数*1.5
                        // 2、	若外盘星体为日月水金木，对内盘成相星体宫位造成的
                        // 破坏为 外盘星基本增益能量*容许系数*0.25；
                        // 增益为 外盘星基本增益能量*容许系数*0.6
                        //【对外盘星所在宫位的破坏，也按上述步骤计算】
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (in_array($i, [4, 6, 7, 8, 9]))
                            {
                                if (in_array($i, [7, 8, 9]) && in_array($phase['id'], [7, 8, 9])) continue;
                                if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $o * 2;
                            } elseif (in_array($i, [0, 1, 2, 3, 5]))
                            {
                                if (isset($good[$phase['id']])) $hg[$h2] += $good[$phase['id']] * $o * 0.6;
                                if (isset($good[$phase['id']])) $hb[$h2] += $good[$phase['id']] * $o * 0.25;
                            }
                        }
                    }
                }
                if ($phase0_num == 1)
                {
                    if (isset($good[$i])) $hg[$h2] += $good[$i] * $first;
                    if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $first;
                } elseif ($phase0_num > 1)
                {
                    if (isset($good[$i])) $hg[$h2] += $good[$i] * $first + $good[$i] * $second * 0.5;
                    if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $first + $bad[$i] * $second * 0.5;
                }
            }

            if (!empty($planet2['phase']))
            {
                $phase0_num = 0;
                $first = 8;
                $second = 8;
                $h_f = NULL;
                $h_s = NULL;
                $h = NULL;
                foreach ($planet2['phase'] as $phase)
                {
                    if (!in_array($phase['id'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, ASC, MC])) continue;
                    if ($phase['id'] == ASC)
                    {
                        // 合上升
                        if ($phase['phase_e'] == 0)
                        {
                            if (isset($good[$i])) $hg[1] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[1] += $bad[$i] + 15;
                        } // 合下降
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (isset($good[$i])) $hg[7] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[7] += $bad[$i] + 15;
                        }
                    } elseif ($phase['id'] == MC)
                    {
                        // 合天顶
                        if ($phase['phase_e'] == 0)
                        {
                            if (isset($good[$i])) $hg[10] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[10] += $bad[$i] + 15;
                        } // 合天底
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (isset($good[$i])) $hg[4] += $good[$i] + 15;
                            if (isset($bad[$i])) $hb[4] += $bad[$i] + 15;
                        }
                    } else
                    {
                        // 容许系数
                        $_orb = $phase['phase_orb'];
                        if ($_orb < 0.5) $o = 1;
                        elseif ($_orb < 1.5) $o = 0.9;
                        elseif ($_orb < 3) $o = 0.85;
                        elseif ($_orb <= 5) $o = 0.8;
                        else $o = 0.75;
                        $h = $planet2['in_house_id'];// 外盘星体落在底盘中的宫位
                        $h2 = $planets2_2[$phase['id']]['in_house_id'];// 底盘星体所在宫位
                        // 若与内盘某星成合相，该宫位增益能量或破坏能量+相应的外盘星体基本能量*容许系数
                        // （多颗星则以最紧密的相位计算，再加上次紧密的相位的一半）
                        if ($phase['phase_e'] == 0)
                        {
                            $phase0_num++;
                            if ($phase0_num == 0)
                            {
                                $first = $o;
                                $h_f = $h2;
                            } elseif ($o < $first)
                            {
                                $second = $first;
                                $first = $o;
                                $h_s = $h_f;
                                $h_f = $h2;
                            } elseif ($o > $first && $o < $second)
                            {
                                $second = $o;
                                $h_s = $h2;
                            }
                        }
                        // 若与内盘星体成六分相，检测成相星体所在宫位，该宫位增益能量+相应的外盘星体基本能量*容许系数*0.5（无破坏）
                        // 外盘星体所在宫位的增益能量+成相星体的基本能量*容许系数*0.5
                        elseif ($phase['phase_e'] == 60)
                        {
                            if (isset($good[$i])) $hg[$h2] += $good[$i] * $o * 0.5;
                            if (isset($good[$phase['id']])) $hg[$h] += $good[$phase['id']] * $o * 0.5;
                        }
                        // 若与内盘星体成四分相，分两种情况计算
                        // 1、	若外盘星体为火土天海冥（对双方都是天海冥的相位不予计算），对内盘成相星体宫位造成的破坏为
                        //  外盘星基本破坏能量*容许系数*2
                        // 2、	若外盘星体为日月水金木，对内盘成相星体宫位造成的
                        // 破坏为 外盘星基本增益能量*容许系数*0.3；
                        // 增益为 外盘星基本增益能量*容许系数*0.1
                        // 【对外盘星所在宫位的破坏，也按上述步骤计算】
                        elseif ($phase['phase_e'] == 90)
                        {
                            if (in_array($i, [4, 6, 7, 8, 9]))
                            {
                                if (in_array($i, [7, 8, 9]) && in_array($phase['id'], [7, 8, 9])) continue;
                                if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $o * 2;
                            } elseif (in_array($i, [0, 1, 2, 3, 5]))
                            {
                                if (isset($good[$phase['id']])) $hg[$h2] += $good[$phase['id']] * $o * 0.1;
                                if (isset($good[$phase['id']])) $hb[$h2] += $good[$phase['id']] * $o * 0.3;
                            }
                        }
                        // 若与内盘星体成三分相，检测成相星体所在宫位，该宫位增益能量+相应的外盘星体基本能量*容许系数*0.6（无破坏）
                        // 外盘星体所在宫位的增益能量+成相星体的基本能量*容许系数*0.6
                        elseif ($phase['phase_e'] == 120)
                        {
                            if (isset($good[$i])) $hg[$h2] += $good[$i] * $o * 0.6;
                            if (isset($good[$phase['id']])) $hg[$h] += $good[$phase['id']] * $o * 0.6;
                        }
                        // 若与内盘星体成对分相，分两种情况计算
                        // 1、	若外盘星体为火土天海冥（对双方都是天海冥的相位不予计算），对内盘成相星体宫位造成的破坏为
                        // 外盘星基本破坏能量*容许系数*1.5
                        // 2、	若外盘星体为日月水金木，对内盘成相星体宫位造成的
                        // 破坏为 外盘星基本增益能量*容许系数*0.25；
                        // 增益为 外盘星基本增益能量*容许系数*0.6
                        //【对外盘星所在宫位的破坏，也按上述步骤计算】
                        elseif ($phase['phase_e'] == 180)
                        {
                            if (in_array($i, [4, 6, 7, 8, 9]))
                            {
                                if (in_array($i, [7, 8, 9]) && in_array($phase['id'], [7, 8, 9])) continue;
                                if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $o * 2;
                            } elseif (in_array($i, [0, 1, 2, 3, 5]))
                            {
                                if (isset($good[$phase['id']])) $hg[$h2] += $good[$phase['id']] * $o * 0.6;
                                if (isset($good[$phase['id']])) $hb[$h2] += $good[$phase['id']] * $o * 0.25;
                            }
                        }
                    }
                }
                if ($phase0_num == 1)
                {
                    if (isset($good[$i])) $hg[$h2] += $good[$i] * $first;
                    if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $first;
                } elseif ($phase0_num > 1)
                {
                    if (isset($good[$i])) $hg[$h2] += $good[$i] * $first + $good[$i] * $second * 0.5;
                    if (isset($bad[$i])) $hb[$h2] += $bad[$i] * $first + $bad[$i] * $second * 0.5;
                }
            }
        }
        return [$hg, $hb];
    }

    /**
     * 获取行星和谐度和冲突度
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     * @return array
     */
    protected function getTheHarmoniousAndConflict($data1 = [], $data2 = [], $debug = false)
    {
        $ret = [0, 0];// 和谐度|冲突度
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);
        $planets1 = $data1['details1']['planets'];
        $planets2 = $data1['details2']['planets'];
        $total = $coef1['obverse'][0] + $coef1['versa'][0] + $coef2['obverse'][0] + $coef2['versa'][0]
            + $coef1['obverse'][1] + $coef1['versa'][1] + $coef2['obverse'][1] + $coef2['versa'][1]
            + $coef1['obverse'][2] + $coef1['versa'][2] + $coef2['obverse'][2] + $coef2['versa'][2]
            + $coef1['obverse'][3] + $coef1['versa'][3] + $coef2['obverse'][3] + $coef2['versa'][3]
            + $coef1['obverse'][4] + $coef1['versa'][4] + $coef2['obverse'][4] + $coef2['versa'][4]
            + $coef1['obverse'][ASC] + $coef1['versa'][ASC] + $coef2['obverse'][ASC] + $coef2['versa'][ASC]
            + $coef1['obverse'][MC] + $coef1['versa'][MC] + $coef2['obverse'][MC] + $coef2['versa'][MC];
//        if($debug) echo "总分值：$total\n";
        foreach ($planets2 as $i => $pl)
        {
            if ($i < 5 || $i == ASC || $i == MC)
            {
                $sum = $coef1['obverse'][$i] + $coef1['versa'][$i] + $coef2['obverse'][$i] + $coef2['versa'][$i];
                // 20190104 Division by zero问题处理
                if ($sum == 0 || $total == 0 || $this->base[$i] == 0) break;

                $a = $sum / $total * 7 * $this->base[$i];
                if ($sum)
                {
                    $scale1 = ($coef1['obverse'][$i] + $coef2['obverse'][$i]) / $sum;
                    $scale2 = ($coef1['versa'][$i] + $coef2['versa'][$i]) / $sum;
//                    if($debug) echo "$i:$scale1|$scale2|$sum\n";
                    $ret[0] += $scale1 * $a;
                    $ret[1] += $scale2 * $a;
                }

            }
        }

        $d = [0, 0, 0, 0, 0, 0, 0, 0];
        for ($k = 0; $k < 10; $k++)
        {
            if (!empty($planets1[$k]['phase']))
            {
                $is_main_060120_1 = false;
                foreach ($planets1[$k]['phase'] as $phase)
                {
                    $a = $b = $c = 0;
                    if ($phase['phase_orb'] < 0.5) $phase_o = 1;
                    elseif ($phase['phase_orb'] < 1.5) $phase_o = 0.9;
                    elseif ($phase['phase_orb'] < 3) $phase_o = 0.85;
                    elseif ($phase['phase_orb'] <= 5) $phase_o = 0.8;
                    elseif ($phase['phase_orb'] > 5) $phase_o = 0.75;

                    if (in_array($k, [7, 8, 9]) || in_array($phase['id'], [7, 8, 9]))
                    {
                        if ($phase['phase_orb'] < 0.5) $phase_o = 1;
                        elseif ($phase['phase_orb'] < 1) $phase_o = 0.9;
                        elseif ($phase['phase_orb'] < 2) $phase_o = 0.7;
                        elseif ($phase['phase_orb'] <= 3) $phase_o = 0.4;
                        elseif ($phase['phase_orb'] > 3) $phase_o = 0.1;
                    }
                    // 凶星刑冲合主星
                    if ($k < 5 && in_array($phase['id'], [4, 6, 7, 8, 9]))
                    {
                        $infortune = [4 => 7, 6 => 15, 7 => 3, 8 => 2, 9 => 2];
                        $main = [10, 15, 7, 8, 5];
                        $phase_base = [0 => 0.2, 90 => 0.7, 180 => 0.4];
                        if (in_array($phase['id'], [0, 1, 3, 5]) && $phase['phase_orb'] <= 2 && in_array($phase['phase_e'], [0, 60, 120]))
                        {
                            $is_main_060120_1 = true;
                        }
                        if (in_array($phase['phase_e'], [0, 90, 180]))
                        {
                            $a = $infortune[$phase['id']];
                            $b = $main[$k];
                            $c = $phase_base[$phase['phase_e']];
                            if ($k == $data1['details1']['houses'][1]['protect_id']
                                || $k == $data1['details1']['houses'][1]['protect_ancient_id'])
                            {
                                $b += 3;
                            }
                            $d[0] += ($a + $b) * $c * $phase_o;
                            if ($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[0]} += ($a+$b)*$c*$phase_o\n";
                        }
                    } // 凶星刑冲合轴点
                    elseif (in_array($k, [4, 6, 7, 8, 9]) && in_array($phase['id'], [ASC, MC]))
                    {
                        $infortune = [4 => 12, 6 => 8, 7 => 8, 8 => 5, 9 => 3];
                        $pivot = [ASC => 15, MC => 14];
                        $phase_base = [0 => 0.8, 90 => 0.2, 180 => 0.6];
                        if (in_array($phase['phase_e'], [0, 90, 180]))
                        {
                            $a = $infortune[$k];
                            $b = $pivot[$phase['id']];
                            $c = $phase_base[$phase['phase_e']];
                            $d[1] += ($a + $b) * $c * $phase_o;
                            if ($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[1]} += ($a+$b)*$c*$phase_o\n";
                        }
                    } // 主星相互刑冲
                    elseif ($k < 4 && in_array($phase['id'], [0, 1, 2, 3]))
                    {
                        $main = [14, 16, 7, 10];
                        $phase_base = [90 => 0.35, 180 => 0.1];
                        if (in_array($phase['phase_e'], [90, 180]))
                        {
                            $a = $main[$k];
                            $b = $main[$phase['id']];
                            $c = $phase_base[$phase['phase_e']];
                            $d[2] += ($a + $b) * $c * $phase_o;
                            if ($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[2]} += ($a+$b)*$c*$phase_o\n";
                        }
                    } // 主星刑四轴
                    elseif ($k < 4 && in_array($phase['id'], [ASC, MC]))
                    {
                        $main = [14, 16, 7, 10];
                        $pivot = [ASC => 16, MC => 15];
                        $phase_base = [90 => 0.2];
                        if ($phase['phase_e'] == 90)
                        {
                            $a = $main[$k];
                            $b = $pivot[$phase['id']];
                            $c = $phase_base[$phase['phase_e']];
                            $d[3] += ($a + $b) * $c * $phase_o;
                            if ($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[3]} += ($a+$b)*$c*$phase_o\n";
                        }
                    }
                }
                if ($is_main_060120_1 === false)
                {
//                    $d[0] *= 1.3;
//                    if($debug) echo "{$d[0]} *= 1.3\n";
                }
            }
//            if(!empty($planets2[$k]['phase']))
//            {
//                $is_main_060120_2 = false;
//                foreach ($planets2[$k]['phase'] as $phase)
//                {
//                    $a=$b=$c=0;
//                    if($phase['phase_orb'] < 0.5) $phase_o = 1;
//                    elseif($phase['phase_orb'] < 1.5) $phase_o = 0.9;
//                    elseif($phase['phase_orb'] < 3) $phase_o = 0.85;
//                    elseif($phase['phase_orb'] <= 5) $phase_o = 0.8;
//                    elseif($phase['phase_orb'] > 5) $phase_o = 0.75;
//
//                    if(in_array($k,[7,8,9]) || in_array($phase['id'],[7,8,9]))
//                    {
//                        if($phase['phase_orb'] < 0.5) $phase_o = 1;
//                        elseif($phase['phase_orb'] < 1) $phase_o = 0.9;
//                        elseif($phase['phase_orb'] < 2) $phase_o = 0.7;
//                        elseif($phase['phase_orb'] <= 3) $phase_o = 0.4;
//                        elseif($phase['phase_orb'] > 3) $phase_o = 0.1;
//                    }
//                    // 凶星刑冲合主星
//                    if($k < 5 && in_array($phase['id'],[4,6,7,8,9]))
//                    {
//                        $infortune = [4=>7,6=>15,7=>3,8=>2,9=>2];
//                        $main = [10,15,7,8,5];
//                        $phase_base = [0=>0.2,90=>0.7,180=>0.4];
//                        if(in_array($phase['id'],[0,1,3,5]) && $phase['phase_orb'] <= 2 && in_array($phase['phase_e'],[0,60,120]))
//                        {
//                            $is_main_060120_2 = true;
//                        }
//                        if(in_array($phase['phase_e'],[0,90,180]))
//                        {
//                            $a = $infortune[$phase['id']];
//                            $b = $main[$k];
//                            $c = $phase_base[$phase['phase_e']];
//                            if($k == $data1['details1']['houses'][1]['protect_id']
//                                || $k == $data1['details1']['houses'][1]['protect_ancient_id'])
//                            {
//                                $b += 3;
//                            }
//                            $d[4] += ($a+$b)*$c*$phase_o;
//                            if($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[4]} += ($a+$b)*$c*$phase_o\n";
//                        }
//                    }
//                    // 凶星刑冲合轴点
//                    elseif(in_array($k,[4,6,7,8,9]) && in_array($phase['id'],[ASC,MC]))
//                    {
//                        $infortune = [4=>12,6=>8,7=>8,8=>5,9=>3];
//                        $pivot = [ASC=>15,MC=>14];
//                        $phase_base = [0=>0.8,90=>0.2,180=>0.6];
//                        if(in_array($phase['phase_e'],[0,90,180]))
//                        {
//                            $a = $infortune[$k];
//                            $b = $pivot[$phase['id']];
//                            $c = $phase_base[$phase['phase_e']];
//                            $d[5] += ($a+$b)*$c*$phase_o;
//                            if($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[5]} += ($a+$b)*$c*$phase_o\n";
//                        }
//                    }
//                    // 主星相互刑冲
//                    elseif($k < 4 && in_array($phase['id'],[0,1,2,3]))
//                    {
//                        $main = [14,16,7,10];
//                        $phase_base = [90=>0.35,180=>0.1];
//                        if(in_array($phase['phase_e'],[90,180]))
//                        {
//                            $a = $main[$k];
//                            $b = $main[$phase['id']];
//                            $c = $phase_base[$phase['phase_e']];
//                            $d[6] += ($a+$b)*$c*$phase_o;
//                            if($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[6]} += ($a+$b)*$c*$phase_o\n";
//                        }
//                    }
//                    // 主星刑四轴
//                    elseif($k < 4 && in_array($phase['id'],[ASC,MC]))
//                    {
//                        $main = [14,16,7,10];
//                        $pivot = [ASC=>16,MC=>15];
//                        $phase_base = [90=>0.2];
//                        if($phase['phase_e'] == 90)
//                        {
//                            $a = $main[$k];
//                            $b = $pivot[$phase['id']];
//                            $c = $phase_base[$phase['phase_e']];
//                            $d[7] += ($a+$b)*$c*$phase_o;
//                            if($debug) echo "行星:{$k}行星：{$phase['id']}相位：{$phase['phase_e']}==>{$d[7]} += ($a+$b)*$c*$phase_o\n";
//                        }
//                    }
//                }
//                if($is_main_060120_2 === false)
//                {
////                    $d[4] *= 1.3;
////                    if($debug) echo "{$d[4]} *= 1.3\n";
//                }
//            }
        }
        if ($debug) echo "和谐度:{$ret[0]}\n冲突度：{$ret[1]}\n";
        if ($debug) echo "冲突度附加数" . (array_sum($d)) . "\n";


        $ts = array_sum($ret);
        if ($ts === 0)
        {
            return [50, 50];
        }
        if ($ret[0] === 0)
        {
            $harmonious = 0;
        } else
        {
            $harmonious = round($ret[0] / $ts * 100);
        }
        if ($ret[1] === 0)
        {
            $conflict = 0;
        } else
        {
            $conflict = round($ret[1] / $ts * 100);
        }
        if ($debug) echo "和谐度：$harmonious%\n冲突度：$conflict%\n";
        return [$harmonious, $conflict];
//        return $ret;
    }

    /**
     * 合盘-痛点相位、底色星体的寻找
     * 痛点相位，是比较盘上产生负面影响最大的相位，是阻碍一段关系发展的基础
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     */
    protected function getTheMainPhase($data1 = [], $data2 = [], $debug = false)
    {
        $ret = ['main' => [], 'sub' => [], 'max' => ['main' => [0, ''], 'sub' => [0, ''], 'result' => []]];
        $phases1 = $data1['details2']['phase'];// 外圈星id1 底盘星id2
        $phases2 = $data2['details2']['phase'];// 外圈星id1 底盘星id2
        $total1 = $total2 = $max1 = $max2 = 0;
        // 影响值初始化
        $influ = [
            'a' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'b' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'c' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        ];
        foreach ($phases1 as $phase)
        {
            if (!isset($influ['a'][$phase['id1']]))
            {
                $influ['a'][$phase['id1']] = 0;
            }
            if (!isset($influ['c'][$phase['id1']]))
            {
                $influ['c'][$phase['id1']] = 0;
            }
            $phase_orb = $phase['orb'];
            if ($phase_orb < 0.5) $phase_o = 1;
            elseif ($phase_orb < 1.5) $phase_o = 0.9;
            elseif ($phase_orb < 3) $phase_o = 0.85;
            elseif ($phase_orb <= 5) $phase_o = 0.8;
            elseif ($phase_orb > 5) $phase_o = 0.75;
            // 所有的日月轴点的合刑冲相位
            if (
                in_array($phase['id1'], [0, 1, ASC, MC]) &&
                ($phase['phase_deg'] == 0 || $phase['phase_deg'] == 90 || $phase['phase_deg'] == 180)
            )
            {
                $a = [0 => 15, 1 => 20, ASC => 15, MC => 14];// 主体比重
                $b = [4 => 20, 6 => 30, 7 => 12, 8 => 10, 9 => 10];// 凶星比重（合刑冲主）
                $c = [0 => 15, 1 => 16, 2 => 7, 3 => 8, 5 => 5, ASC => 15, MC => 14];// 吉星比重（刑主）
                $d = [0 => 0.4, 90 => 1, 180 => 0.7];// 相位伤害比
                // 凶星
                if (in_array($phase['id2'], [4, 6, 7, 8, 9]))
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $b[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    $ret['main'][] = $phase;
                    $total1 += $phase['proportion'];
                    if ($phase['proportion'] > $max1)
                    {
                        $max1 = $phase['proportion'];
                        $ret['max']['main'] = [$max1, $phase['id1'] . '-' . $phase['id2']];
                    }
                } // 吉星
                elseif (in_array($phase['id2'], [0, 1, 2, 3, 5, ASC, MC]) && $phase['phase_deg'] == 90)
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $c[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    if ($phase['id1'] == $phase['id2']) $phase['proportion'] *= 2;
                    $ret['main'][] = $phase;
                    $total1 += $phase['proportion'];
                    if ($phase['proportion'] > $max1)
                    {
                        $max1 = $phase['proportion'];
                        $ret['max']['main'] = [$max1, $phase['id1'] . '-' . $phase['id2']];
                    }
                }
            } // 所有的金水火的合刑冲相位
            elseif (
                in_array($phase['id1'], [2, 3, 4]) &&
                ($phase['phase_deg'] == 0 || $phase['phase_deg'] == 90 || $phase['phase_deg'] == 180)
            )
            {
                $a = [2 => 7, 3 => 8, 4 => 7];// 主星比重
                $b = [4 => 12, 6 => 18, 7 => 7, 8 => 5, 9 => 5];// 凶星比重（合刑冲主）
                $c = [2 => 7, 3 => 8, 5 => 4];// 吉星比重（刑主）
                $d = [0 => 0.4, 90 => 1, 180 => 0.7];// 相位伤害比
                // 凶星
                if (in_array($phase['id2'], [4, 6, 7, 8, 9]))
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $b[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    $ret['sub'][] = $phase;
                    $total2 += $phase['proportion'];
                    if ($phase['proportion'] > $max2)
                    {
                        $max2 = $phase['proportion'];
                        $ret['max']['sub'] = [$max2, $phase['id1'] . '-' . $phase['id2']];
                    }
                } // 吉星
                elseif (in_array($phase['id2'], [2, 3, 5]) && $phase['phase_deg'] == 90)
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $c[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    if ($phase['id1'] == $phase['id2']) $phase['proportion'] *= 2;
                    $ret['sub'][] = $phase;
                    $total2 += $phase['proportion'];
                    if ($phase['proportion'] > $max2)
                    {
                        $max2 = $phase['proportion'];
                        $ret['max']['sub'] = [$max2, $phase['id1'] . '-' . $phase['id2']];
                    }
                }
            }
            if (in_array($phase['id1'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12]) && in_array($phase['id2'], [0, 1, 2, 3, 4, ASC, MC]))
            {

                $a = [0 => 15, 1 => 20, 2 => 8, 3 => 7, 4 => 7, ASC => 15, MC => 14];// 主体比重
                $d = [0 => 1, 60 => 0.7, 90 => 0.8, 120 => 0.8, 180 => 0.9];// 相位系数
                if (isset($a[$phase['id2']]) && isset($d[$phase['phase_deg']]))
                {
                    $influ['a'][$phase['id1']] += $a[$phase['id2']] * $d[$phase['phase_deg']] * $phase_o;
                    $influ['c'][$phase['id1']] += $a[$phase['id2']] * $d[$phase['phase_deg']] * $phase_o;
                }
            }
        }
        foreach ($phases2 as $phase)
        {
            $phase_orb = $phase['orb'];
            if ($phase_orb < 0.5) $phase_o = 1;
            elseif ($phase_orb < 1.5) $phase_o = 0.9;
            elseif ($phase_orb < 3) $phase_o = 0.85;
            elseif ($phase_orb <= 5) $phase_o = 0.8;
            elseif ($phase_orb > 5) $phase_o = 0.75;
            if (!isset($influ['b'][$phase['id1']]))
            {
                $influ['b'][$phase['id1']] = 0;
            }
            if (!isset($influ['c'][$phase['id1']]))
            {
                $influ['c'][$phase['id1']] = 0;
            }
            // 所有的日月轴点的合刑冲相位
            if (
                in_array($phase['id1'], [0, 1, ASC, MC]) &&
                ($phase['phase_deg'] == 0 || $phase['phase_deg'] == 90 || $phase['phase_deg'] == 180)
            )
            {
                $a = [0 => 15, 1 => 20, ASC => 15, MC => 14];// 主体比重
                $b = [4 => 20, 6 => 30, 7 => 12, 8 => 10, 9 => 10];// 凶星比重（合刑冲主）
                $c = [0 => 15, 1 => 16, 2 => 7, 3 => 8, 5 => 5, ASC => 15, MC => 14];// 吉星比重（刑主）
                $d = [0 => 0.4, 90 => 1, 180 => 0.7];// 相位伤害比
                // 凶星
                if (in_array($phase['id2'], [4, 6, 7, 8, 9]))
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $b[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    $ret['main'][] = $phase;
                    $total1 += $phase['proportion'];
                    if ($phase['proportion'] > $max1)
                    {
                        $max1 = $phase['proportion'];
                        $ret['max']['main'] = [$max1, $phase['id1'] . '-' . $phase['id2']];
                    }
                } // 吉星
                elseif (in_array($phase['id2'], [0, 1, 2, 3, 5, ASC, MC]) && $phase['phase_deg'] == 90)
                {
                    if ($phase['id1'] == $phase['id2']) continue;
                    $phase['proportion'] = ($a[$phase['id1']] + $c[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    $ret['main'][] = $phase;
                    $total1 += $phase['proportion'];
                    if ($phase['proportion'] > $max1)
                    {
                        $max1 = $phase['proportion'];
                        $ret['max']['main'] = [$max1, $phase['id1'] . '-' . $phase['id2']];
                    }
                }
            } // 所有的金水火的合刑冲相位
            elseif (
                in_array($phase['id1'], [2, 3, 4]) &&
                ($phase['phase_deg'] == 0 || $phase['phase_deg'] == 90 || $phase['phase_deg'] == 180)
            )
            {
                $a = [2 => 7, 3 => 8, 4 => 7];// 主星比重
                $b = [4 => 12, 6 => 18, 7 => 7, 8 => 5, 9 => 5];// 凶星比重（合刑冲主）
                $c = [2 => 7, 3 => 8, 5 => 4];// 吉星比重（刑主）
                $d = [0 => 0.4, 90 => 1, 180 => 0.7];// 相位伤害比
                // 凶星
                if (in_array($phase['id2'], [4, 6, 7, 8, 9]))
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $b[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    $ret['sub'][] = $phase;
                    $total2 += $phase['proportion'];
                    if ($phase['proportion'] > $max2)
                    {
                        $max2 = $phase['proportion'];
                        $ret['max']['sub'] = [$max2, $phase['id1'] . '-' . $phase['id2']];
                    }
                } // 吉星
                elseif (in_array($phase['id2'], [2, 3, 5]) && $phase['phase_deg'] == 90)
                {
                    $phase['proportion'] = ($a[$phase['id1']] + $c[$phase['id2']]) * $d[$phase['phase_deg']] * $phase_o;
                    if ($phase['id1'] == $phase['id2']) $phase['proportion'] *= 2;
                    $ret['sub'][] = $phase;
                    $total2 += $phase['proportion'];
                    if ($phase['proportion'] > $max2)
                    {
                        $max2 = $phase['proportion'];
                        $ret['max']['sub'] = [$max2, $phase['id1'] . '-' . $phase['id2']];
                    }
                }
            }
            if (in_array($phase['id1'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12]) && in_array($phase['id2'], [0, 1, 2, 3, 4, ASC, MC]))
            {
                $a = [0 => 15, 1 => 20, 2 => 8, 3 => 7, 4 => 7, ASC => 15, MC => 14];// 主体比重
                $d = [0 => 1, 60 => 0.7, 90 => 0.8, 120 => 0.8, 180 => 0.9];// 相位系数
                if (isset($a[$phase['id2']]) && isset($d[$phase['phase_deg']]))
                {
                    $influ['b'][$phase['id1']] += $a[$phase['id2']] * $d[$phase['phase_deg']] * $phase_o;
                    $influ['c'][$phase['id1']] += $a[$phase['id2']] * $d[$phase['phase_deg']] * $phase_o;
                }
            }
        }
        $ret['total'] = [$total1, $total2, $total1 + $total2];
        if ($ret['max']['main'][0] == 0 || $ret['max']['main'][0] < $ret['max']['sub'][0])
        {
            $ret['max']['result'] = $ret['max']['sub'];
        } else
        {
            $ret['max']['result'] = $ret['max']['main'];
        }
        $ret['influ'] = $influ;

        $keya = array_search(max($influ['a']), $influ['a']);// a对b
        $keyb = array_search(max($influ['b']), $influ['b']);// b对a
        $keyc = array_search(max($influ['c']), $influ['c']);// 内外相加后
        if ($debug) echo "甲对乙：行星$keya\n乙对甲：行星$keyb\n内外相加：行星$keyc\n";
        if ($debug) p($ret);
        return $ret;
    }

    /**
     * 立足点词条输出
     * 矛盾点词条输出
     * 双方得失分数计算
     * @param array $data1
     * @param array $data2
     * @param int $attract 吸引分数
     * @param int $chat
     * @param int $passion 激情分数
     * @param int $benefit
     * @param int $happy
     * @param int $probTobeLover
     * @param array $harmoniousAndConflict
     * @param array $relation
     */
    protected function getFoothold($data1 = [], $data2 = [], $attract = 0, $chat = 0, $passion = 0, $benefit = 0, $happy = 0, $probTobeLover = 0, $harmoniousAndConflict = [], $relation = [])
    {
        $ret = [];
        $pls1 = $data1['details1']['planets'];
        $pls2 = $data2['details1']['planets'];
        $pls1_2 = $data1['details2']['planets'];
        $pls2_2 = $data2['details2']['planets'];

        $foothold_1 = $foothold_2 = $foothold_3 = $foothold_4
            = $foothold_5 = $foothold_6 = $foothold_7 = $foothold_8
            = $foothold_9 = $foothold_10 = $foothold_11 = $foothold_12
            = $foothold_13 = $foothold_14 = $foothold_15 = $foothold_16 = 0;
        $temp1_1 = [0, 1, 3, 5];// 日月金木
        foreach ($temp1_1 as $t1_1)
        {
            // 一方日、月、金或木星合另一方天顶
            if (isset($pls1[$t1_1]['phase'][$t1_1 . '-' . MC]) && $pls1[$t1_1]['phase'][$t1_1 . '-' . MC]['phase_e'] == 0)
            {
                // 不与日月火土海刑冲+2
                if (
                    (
                        !isset($pls1[$t1_1]['phase'][$t1_1 . '-0'])
                        || !in_array($pls1[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls1[$t1_1]['phase'][$t1_1 . '-1'])
                        || !in_array($pls1[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls1[$t1_1]['phase'][$t1_1 . '-4'])
                        || !in_array($pls1[$t1_1]['phase'][$t1_1 . '-4']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls1[$t1_1]['phase'][$t1_1 . '-6'])
                        || !in_array($pls1[$t1_1]['phase'][$t1_1 . '-6']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls1[$t1_1]['phase'][$t1_1 . '-8'])
                        || !in_array($pls1[$t1_1]['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                    )
                )
                {
                    $foothold_1 += 2;
                }
                // 与日月火土海刑冲+1
                if (
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-0'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-1'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-4'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-4']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-6'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-8'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                    )
                )
                {
                    $foothold_1 += 1;
                }
                // 与日月金木合拱六分+3
                if (
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-0'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-1'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-3'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[$t1_1]['phase'][$t1_1 . '-5'])
                        && in_array($pls1[$t1_1]['phase'][$t1_1 . '-5']['phase_e'], [0, 60, 120])
                    )
                )
                {
                    $foothold_1 += 3;
                }
            }
            // 一方日、月、金或木星合另一方天顶
            if (isset($pls2[$t1_1]['phase'][$t1_1 . '-' . MC]) && $pls2[$t1_1]['phase'][$t1_1 . '-' . MC]['phase_e'] == 0)
            {
                // 不与日月火土海刑冲+2
                if (
                    (
                        !isset($pls2[$t1_1]['phase'][$t1_1 . '-0'])
                        || !in_array($pls2[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls2[$t1_1]['phase'][$t1_1 . '-1'])
                        || !in_array($pls2[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls2[$t1_1]['phase'][$t1_1 . '-4'])
                        || !in_array($pls2[$t1_1]['phase'][$t1_1 . '-4']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls2[$t1_1]['phase'][$t1_1 . '-6'])
                        || !in_array($pls2[$t1_1]['phase'][$t1_1 . '-6']['phase_e'], [90, 180])
                    )
                    &&
                    (
                        !isset($pls2[$t1_1]['phase'][$t1_1 . '-8'])
                        || !in_array($pls2[$t1_1]['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                    )
                )
                {
                    $foothold_1 += 2;
                }
                // 与日月火土海刑冲+1
                if (
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-0'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-1'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-4'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-4']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-6'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-8'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                    )
                )
                {
                    $foothold_1 += 1;
                }
                // 与日月金木合拱六分+3
                if (
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-0'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-1'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-3'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[$t1_1]['phase'][$t1_1 . '-5'])
                        && in_array($pls2[$t1_1]['phase'][$t1_1 . '-5']['phase_e'], [0, 60, 120])
                    )
                )
                {
                    $foothold_1 += 3;
                }
            }
        }
        // 日月水金火
        for ($i = 0; $i < 5; $i++)
        {
            $ph10_a1 = $pls1[$i];// 本命1
            $ph10_b1 = $pls2[$i];// 本命2
            if (!empty($ph10_a1['phase']))
            {
                foreach ($ph10_a1['phase'] as $ph10a1)
                {
                    $id2 = $ph10a1['id'];
                    // 一方10宫内的日月金水火与另一方日月金木成合拱六分相
                    if (
                        $ph10_a1['in_house_id'] == 10
                        && in_array($id2, $temp1_1)
                        && in_array($ph10a1['phase_e'], [0, 60, 120])
                    )
                    {
                        // 有日月参与 +2
                        if (in_array($i, [0, 1]) || in_array($id2, [0, 1]))
                        {
                            $foothold_1 += 2;
                            // 是日月相位再+1
                            if (($i == 0 && $id2 == 1) || ($i == 1 && $id2 == 2))
                            {
                                $foothold_1 += 1;
                            }
                        } // 无日月参与 +1
                        else
                        {
                            $foothold_1 += 1;
                        }
                        // 受火土海刑冲-0.5
                        if (
                            (isset($ph10_a1[$i . '-4']) && in_array($ph10_a1[$i . '-4']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-6']) && in_array($ph10_a1[$i . '-6']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-8']) && in_array($ph10_a1[$i . '-8']['phase_e'], [90, 180]))
                        )
                        {
                            $foothold_1 -= 0.5;
                        }
                    }
                    // 一方6宫内的日月金水火与另一方日月木成合拱六分相
                    if (
                        $ph10_a1['in_house_id'] == 6
                        && in_array($id2, [0, 1, 5])
                        && in_array($ph10a1['phase_e'], [0, 60, 120])
                    )
                    {
                        // 有日月参与 +1.5
                        if (in_array($i, [0, 1]) || in_array($id2, [0, 1]))
                        {
                            $foothold_1 += 1.5;
                            // 是日月相位再+2.5
                            if (($i == 0 && $id2 == 1) || ($i == 1 && $id2 == 2))
                            {
                                $foothold_1 += 2.5;
                            }
                        } // 无日月参与 +1
                        else
                        {
                            $foothold_1 += 1;
                        }
                        // 受火土海刑冲-0.5
                        if (
                            (isset($ph10_a1[$i . '-4']) && in_array($ph10_a1[$i . '-4']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-6']) && in_array($ph10_a1[$i . '-6']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-8']) && in_array($ph10_a1[$i . '-8']['phase_e'], [90, 180]))
                        )
                        {
                            $foothold_1 -= 0.5;
                        }
                    }
                }
            }
            if (!empty($ph10_b1['phase']))
            {
                foreach ($ph10_b1['phase'] as $ph10b1)
                {
                    $id2 = $ph10b1['id'];
                    // 一方10宫内的日月金水火与另一方日月金木成合拱六分相
                    if (
                        $ph10_b1['in_house_id'] == 10
                        && in_array($id2, $temp1_1)
                        && in_array($ph10b1['phase_e'], [0, 60, 120])
                    )
                    {
                        // 有日月参与 +2
                        if (in_array($i, [0, 1]) || in_array($id2, [0, 1]))
                        {
                            $foothold_1 += 2;
                            // 是日月相位再+1
                            if (($i == 0 && $id2 == 1) || ($i == 1 && $id2 == 2))
                            {
                                $foothold_1 += 1;
                            }
                        } // 无日月参与 +1
                        else
                        {
                            $foothold_1 += 1;
                        }
                        // 受火土海刑冲-0.5
                        if (
                            (isset($ph10_a1[$i . '-4']) && in_array($ph10_a1[$i . '-4']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-6']) && in_array($ph10_a1[$i . '-6']['phase_e'], [90, 180]))
                            || (isset($ph10_a1[$i . '-8']) && in_array($ph10_a1[$i . '-8']['phase_e'], [90, 180]))
                        )
                        {
                            $foothold_1 -= 0.5;
                        }
                    }
                    // 一方6宫内的日月金水火与另一方日月木成合拱六分相
                    if (
                        $ph10_b1['in_house_id'] == 6
                        && in_array($id2, [0, 1, 5])
                        && in_array($ph10b1['phase_e'], [0, 60, 120])
                    )
                    {
                        // 有日月参与 +1.5
                        if (in_array($i, [0, 1]) || in_array($id2, [0, 1]))
                        {
                            $foothold_1 += 1.5;
                            // 是日月相位再+2.5
                            if (($i == 0 && $id2 == 1) || ($i == 1 && $id2 == 2))
                            {
                                $foothold_1 += 2.5;
                            }
                        } // 无日月参与 +1
                        else
                        {
                            $foothold_1 += 1;
                        }
                        // 受火土海刑冲-0.5
                        if (
                            (isset($ph10_b1[$i . '-4']) && in_array($ph10_b1[$i . '-4']['phase_e'], [90, 180]))
                            || (isset($ph10_b1[$i . '-6']) && in_array($ph10_b1[$i . '-6']['phase_e'], [90, 180]))
                            || (isset($ph10_b1[$i . '-8']) && in_array($ph10_b1[$i . '-8']['phase_e'], [90, 180]))
                        )
                        {
                            $foothold_1 -= 0.5;
                        }
                    }
                }
            }
        }
        // 一方日月落入对方6或10宫，并与对方日月金木成合拱六分相+2
        // 日月水金火
        for ($i = 0; $i < 5; $i++)
        {
            if ($i < 2)
            {
                if (in_array($pls1_2[$i]['in_house_id'], [6, 10])
                    &&
                    (
                        (isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-3'])
                            && in_array($pls1_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-5'])
                            && in_array($pls1_2[$i]['phase'][$i . '-5']['phase_e'], [0, 60, 120]))
                    ))
                {
                    // 受火土海刑冲-0.5
                    if (
                        (isset($pls1_2[$i]['phase'][$i . '-4'])
                            && in_array($pls1_2[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-6'])
                            && in_array($pls1_2[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-8'])
                            && in_array($pls1_2[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    )
                    {
                        $foothold_1 -= 0.5;
                    }
                }
                if (in_array($pls2_2[$i]['in_house_id'], [6, 10])
                    &&
                    (
                        (isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-3'])
                            && in_array($pls2_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-5'])
                            && in_array($pls2_2[$i]['phase'][$i . '-5']['phase_e'], [0, 60, 120]))
                    ))
                {
                    // 受火土海刑冲-0.5
                    if (
                        (isset($pls2_2[$i]['phase'][$i . '-4'])
                            && in_array($pls2_2[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-6'])
                            && in_array($pls2_2[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-8'])
                            && in_array($pls2_2[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    )
                    {
                        $foothold_1 -= 0.5;
                    }
                }
            } else
            {
                if (in_array($pls1_2[$i]['in_house_id'], [6, 10])
                    &&
                    (
                        (isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-3'])
                            && in_array($pls1_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-5'])
                            && in_array($pls1_2[$i]['phase'][$i . '-5']['phase_e'], [0, 60, 120]))
                    ))
                {
                    // 日月参与 +2
                    if ((isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120])))
                    {
                        $foothold_1 += 2;
                    } // 日月不参与 +1
                    else
                    {
                        $foothold_1 += 1;
                    }
                    // 受火土海刑冲-0.5
                    if (
                        (isset($pls1_2[$i]['phase'][$i . '-4'])
                            && in_array($pls1_2[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-6'])
                            && in_array($pls1_2[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                        ||
                        (isset($pls1_2[$i]['phase'][$i . '-8'])
                            && in_array($pls1_2[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    )
                    {
                        $foothold_1 -= 0.5;
                    }
                }

                if (in_array($pls2_2[$i]['in_house_id'], [6, 10])
                    &&
                    (
                        (isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-3'])
                            && in_array($pls2_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-5'])
                            && in_array($pls2_2[$i]['phase'][$i . '-5']['phase_e'], [0, 60, 120]))
                    ))
                {
                    // 日月参与 +2
                    if ((isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120])))
                    {
                        $foothold_1 += 2;
                    } // 日月不参与 +1
                    else
                    {
                        $foothold_1 += 1;
                    }
                    // 受火土海刑冲-0.5
                    if (
                        (isset($pls2_2[$i]['phase'][$i . '-4'])
                            && in_array($pls2_2[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-6'])
                            && in_array($pls2_2[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                        ||
                        (isset($pls2_2[$i]['phase'][$i . '-8'])
                            && in_array($pls2_2[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    )
                    {
                        $foothold_1 -= 0.5;
                    }
                }
            }
        }
        if ($foothold_1 >= 3)
        {
            $ret[] = '在共同事业或工作中的帮助与良好互动';
        }
//        p($foothold_1);
        ##########################1在共同事业或工作中的帮助与良好互动 END 3分合格#################################


        ##########################2志趣相投，谈天说地轻松愉悦start###############################################
        $foothold_2_bad = 0;
        // 水星与水星吉相
        if (isset($pls1[2]['phase']['2-2']))
        {
            // 合拱 +2
            if (in_array($pls1[2]['phase']['2-2']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2;
            } // 六分 +1
            elseif ($pls1[2]['phase']['2-2']['phase_e'] == 60)
            {
                $foothold_2 += 1;
            }
        }
        // 水星与木星吉相
        if (isset($pls1[2]['phase']['2-5']))
        {
            // 合拱 +3
            if (in_array($pls1[2]['phase']['2-5']['phase_e'], [0, 120]))
            {
                $foothold_2 += 3;
            } // 六分 +1.5
            elseif ($pls1[2]['phase']['2-5']['phase_e'] == 60)
            {
                $foothold_2 += 1.5;
            }
        }
        if (isset($pls1[5]['phase']['5-2']))
        {
            // 合拱 +3
            if (in_array($pls1[5]['phase']['5-2']['phase_e'], [0, 120]))
            {
                $foothold_2 += 3;
            } // 六分 +1.5
            elseif ($pls1[5]['phase']['5-2']['phase_e'] == 60)
            {
                $foothold_2 += 1.5;
            }
        }
        // 水星与月亮吉相
        if (isset($pls1[2]['phase']['2-1']))
        {
            // 合拱 +2.5
            if (in_array($pls1[2]['phase']['2-1']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2.5;
            } // 六分 +1.5
            elseif ($pls1[2]['phase']['2-1']['phase_e'] == 60)
            {
                $foothold_2 += 1.5;
            }
        }
        if (isset($pls1[1]['phase']['1-2']))
        {
            // 合拱 +2.5
            if (in_array($pls1[1]['phase']['1-2']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2.5;
            } // 六分 +1.5
            elseif ($pls1[1]['phase']['1-2']['phase_e'] == 60)
            {
                $foothold_2 += 1.5;
            }
        }
        // 水星与四轴合拱
        if (isset($pls1[2]['phase']['2-' . ASC]))
        {
            // 合冲上升  即  合上升或合下降 +2
            if (in_array($pls1[2]['phase']['2-' . ASC]['phase_e'], [0, 180]))
            {
                $foothold_2 += 2;
            } // 拱半拱上升  即 拱上升或拱下降 +1
            elseif (in_array($pls1[2]['phase']['2-' . ASC]['phase_e'], [60, 120]))
            {
                $foothold_2 += 1;
            }
        }
        if (isset($pls1[2]['phase']['2-' . MC]))
        {
            // 合冲中天  即  合天顶或合天底 +2
            if (in_array($pls1[2]['phase']['2-' . MC]['phase_e'], [0, 180]))
            {
                $foothold_2 += 2;
            } // 拱半拱中天  即 拱天顶或拱天底 +1
            elseif (in_array($pls1[2]['phase']['2-' . MC]['phase_e'], [60, 120]))
            {
                $foothold_2 += 1;
            }
        }
        if (isset($pls2[2]['phase']['2-' . ASC]))
        {
            // 合冲上升  即  合上升或合下降 +2
            if (in_array($pls2[2]['phase']['2-' . ASC]['phase_e'], [0, 180]))
            {
                $foothold_2 += 2;
            } // 拱半拱上升  即 拱上升或拱下降 +1
            elseif (in_array($pls2[2]['phase']['2-' . ASC]['phase_e'], [60, 120]))
            {
                $foothold_2 += 1;
            }
        }
        if (isset($pls2[2]['phase']['2-' . MC]))
        {
            // 合冲中天  即  合天顶或合天底 +2
            if (in_array($pls2[2]['phase']['2-' . MC]['phase_e'], [0, 180]))
            {
                $foothold_2 += 2;
            } // 拱半拱中天  即 拱天顶或拱天底 +1
            elseif (in_array($pls2[2]['phase']['2-' . MC]['phase_e'], [60, 120]))
            {
                $foothold_2 += 1;
            }
        }
        // 水星与太阳吉相
        if (isset($pls1[2]['phase']['2-0']))
        {
            // 合拱 +2
            if (in_array($pls1[2]['phase']['2-0']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2;
            } // 六分 +1
            elseif ($pls1[2]['phase']['2-0']['phase_e'] == 60)
            {
                $foothold_2 += 1;
            }
        }
        if (isset($pls1[0]['phase']['0-2']))
        {
            // 合拱 +2
            if (in_array($pls1[0]['phase']['0-2']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2;
            } // 六分 +1
            elseif ($pls1[0]['phase']['0-2']['phase_e'] == 60)
            {
                $foothold_2 += 1;
            }
        }
        // 水星与金星吉相
        if (isset($pls1[2]['phase']['2-3']))
        {
            // 合拱 +1.5
            if (in_array($pls1[2]['phase']['2-3']['phase_e'], [0, 120]))
            {
                $foothold_2 += 1.5;
            } // 六分 +0.8
            elseif ($pls1[2]['phase']['2-3']['phase_e'] == 60)
            {
                $foothold_2 += 0.8;
            }
        }
        if (isset($pls1[3]['phase']['3-2']))
        {
            // 合拱 +2
            if (in_array($pls1[3]['phase']['3-2']['phase_e'], [0, 120]))
            {
                $foothold_2 += 2;
            } // 六分 +1
            elseif ($pls1[3]['phase']['3-2']['phase_e'] == 60)
            {
                $foothold_2 += 1;
            }
        }
        // 一方日月金木与对方3/9宫内的日月金水拱六分
        foreach ($temp1_1 as $t2_1)
        {
            $f2_0123_60120_status = [0];
            if (!empty($pls1_2[$t2_1]['phase']))
            {
                foreach ($pls1_2[$t2_1]['phase'] as $ps)
                {
                    if (in_array($pls1[$ps['id']]['in_house_id'], [3, 9])
                        && in_array($pls1[$ps['id']]['id'], [0, 1, 2, 3])
                        && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    )
                    {
                        // 有日月+2
                        if (in_array($t2_1, [0, 1]) || in_array($ps['id'], [0, 1]))
                        {
                            $f2_0123_60120_status[] = 2;
                            // 是日月
                            if (($t2_1 == 0 && $ps['id'] == 1) || ($t2_1 == 1 && $ps['id'] == 0))
                            {
                                $f2_0123_60120_status[] = 3;
                            }
                        } // 无日月 +1
                        else
                        {
                            $f2_0123_60120_status[] = 1;
                        }
                    }
                }
            }
            $foothold_2 += max($f2_0123_60120_status);
            $f2_0123_60120_status = [0];
            if (!empty($pls2_2[$t2_1]['phase']))
            {
                foreach ($pls2_2[$t2_1]['phase'] as $ps)
                {
                    if (in_array($pls2[$ps['id']]['in_house_id'], [3, 9])
                        && in_array($pls2[$ps['id']]['id'], [0, 1, 2, 3])
                        && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    )
                    {
                        // 有日月+2
                        if (in_array($t2_1, [0, 1]) || in_array($ps['id'], [0, 1]))
                        {
                            $f2_0123_60120_status[] = 2;
                            // 是日月
                            if (($t2_1 == 0 && $ps['id'] == 1) || ($t2_1 == 1 && $ps['id'] == 0))
                            {
                                $f2_0123_60120_status[] = 3;
                            }
                        } // 无日月 +1
                        else
                        {
                            $f2_0123_60120_status[] = 1;
                        }
                    }
                }
            }
            $foothold_2 += max($f2_0123_60120_status);
        }
        // 一方日月金水落对方3/9宫，与对方日月金木合拱六分
        $f2_0123 = [0, 1, 2, 3];
        foreach ($f2_0123 as $f)
        {
            $f2_0123_60120_status = [0];
            if (!empty($pls1_2[$f]['phase']))
            {
                foreach ($pls1_2[$f]['phase'] as $ps)
                {
                    if (in_array($pls1[$ps['id']]['in_house_id'], [3, 9])
                        && in_array($pls1[$ps['id']]['id'], $temp1_1)
                        && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    )
                    {
                        // 有日月+2
                        if (in_array($f, [0, 1]) || in_array($ps['id'], [0, 1]))
                        {
                            $f2_0123_60120_status[] = 2;
                            // 是日月
                            if (($f == 0 && $ps['id'] == 1) || ($f == 1 && $ps['id'] == 0))
                            {
                                $f2_0123_60120_status[] = 3;
                            }
                        } // 无日月 +1
                        else
                        {
                            $f2_0123_60120_status[] = 1;
                        }
                    }
                }
            }
            $foothold_2 += max($f2_0123_60120_status);
            $f2_0123_60120_status = [0];
            if (!empty($pls2_2[$f]['phase']))
            {
                foreach ($pls2_2[$f]['phase'] as $ps)
                {
                    if (in_array($pls2[$ps['id']]['in_house_id'], [3, 9])
                        && in_array($pls2[$ps['id']]['id'], $temp1_1)
                        && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    )
                    {
                        // 有日月+2
                        if (in_array($f, [0, 1]) || in_array($ps['id'], [0, 1]))
                        {
                            $f2_0123_60120_status[] = 2;
                            // 是日月
                            if (($f == 0 && $ps['id'] == 1) || ($f == 1 && $ps['id'] == 0))
                            {
                                $f2_0123_60120_status[] = 3;
                            }
                        } // 无日月 +1
                        else
                        {
                            $f2_0123_60120_status[] = 1;
                        }
                    }
                }
            }
            $foothold_2 += max($f2_0123_60120_status);
        }
        // 一方木星落对方3/9宫，与对方日月金水冲合拱六分
        if (in_array($pls1_2[5]['in_house_id'], [3, 9]))
        {
            if (!empty($pls1_2[5]['phase']))
            {
                foreach ($pls1_2[5]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3]) && in_array($ps['phase_e'], [0, 180, 60, 120]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 += 2;
                        } else
                        {
                            $foothold_2 += 1;
                        }
                    }
                }
            }
        }
        if (in_array($pls2_2[5]['in_house_id'], [3, 9]))
        {
            if (!empty($pls2_2[5]['phase']))
            {
                foreach ($pls2_2[5]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3]) && in_array($ps['phase_e'], [0, 180, 60, 120]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 += 2;
                        } else
                        {
                            $foothold_2 += 1;
                        }
                    }
                }
            }
        }
        // 一方土星落对方3、9宫刑冲日月金水火
        if (in_array($pls1_2[6]['in_house_id'], [3, 9]))
        {
            if (!empty($pls1_2[6]['phase']))
            {
                foreach ($pls1_2[6]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3, 4]) && in_array($ps['phase_e'], [90, 180]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 -= 2;
                        } else
                        {
                            $foothold_2 -= 1;
                        }
                    }
                }
            }
        }
        // 一方火星或海王落对方3/9宫刑冲日月金水火
        if (in_array($pls1_2[4]['in_house_id'], [3, 9]))
        {
            if (!empty($pls1_2[4]['phase']))
            {
                foreach ($pls1_2[4]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3, 4]) && in_array($ps['phase_e'], [90, 180]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 -= 1.5;
                        } else
                        {
                            $foothold_2 -= 0.8;
                        }
                    }
                }
            }
        }
        if (in_array($pls2_2[4]['in_house_id'], [3, 9]))
        {
            if (!empty($pls2_2[4]['phase']))
            {
                foreach ($pls2_2[4]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3, 4]) && in_array($ps['phase_e'], [90, 180]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 -= 1.5;
                        } else
                        {
                            $foothold_2 -= 0.8;
                        }
                    }
                }
            }
        }
        if (in_array($pls1_2[8]['in_house_id'], [3, 9]))
        {
            if (!empty($pls1_2[8]['phase']))
            {
                foreach ($pls1_2[8]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3, 4]) && in_array($ps['phase_e'], [90, 180]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 -= 1.5;
                        } else
                        {
                            $foothold_2 -= 0.8;
                        }
                    }
                }
            }
        }
        if (in_array($pls2_2[8]['in_house_id'], [3, 9]))
        {
            if (!empty($pls2_2[8]['phase']))
            {
                foreach ($pls2_2[8]['phase'] as $ps)
                {
                    if (in_array($ps['id'], [0, 1, 2, 3, 4]) && in_array($ps['phase_e'], [90, 180]))
                    {
                        if ($ps['id'] == 0 || $ps['id'] == 1)
                        {
                            $foothold_2 -= 1.5;
                        } else
                        {
                            $foothold_2 -= 0.8;
                        }
                    }
                }
            }
        }
        //   负面
        // 若有水星凶相
        if (!empty($pls1[2]['phase']))
        {
            foreach ($pls1[2]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    if ($ps['id'] == 2)
                    {
                        if ($ps['phase_e'] == 90) $foothold_2_bad -= 1.2;
                    } elseif ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == 4)
                    {
                        $foothold_2_bad -= 1.5;
                    } elseif ($ps['id'] == 6)
                    {
                        $foothold_2_bad -= 2;
                    } elseif ($ps['id'] == 8)
                    {
                        $foothold_2_bad -= 1;
                    }
                }

            }
        }
        if (!empty($pls2[2]['phase']))
        {
            foreach ($pls2[2]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    if ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == 4)
                    {
                        $foothold_2_bad -= 1.5;
                    } elseif ($ps['id'] == 6)
                    {
                        $foothold_2_bad -= 2;
                    } elseif ($ps['id'] == 8)
                    {
                        $foothold_2_bad -= 1;
                    }
                }

            }
        }
        // 月落对方12-1.5
        if ($pls1_2[1]['in_house_id'] == 12)
        {
            $foothold_2_bad -= 1.5;
        }
        if ($pls2_2[1]['in_house_id'] == 12)
        {
            $foothold_2_bad -= 1.5;
        }
        // 水落对方12-1.5
        if ($pls1_2[2]['in_house_id'] == 12)
        {
            $foothold_2_bad -= 1.5;
        }
        if ($pls2_2[2]['in_house_id'] == 12)
        {
            $foothold_2_bad -= 1.5;
        }
        // 火落对方3刑冲日月-1 火落对方7刑冲日月-1
        if ($pls1_2[4]['in_house_id'] == 3 || $pls1_2[4]['in_house_id'] == 7)
        {
            if (
                (isset($pls1_2[4]['phase']['4-0']) && in_array($pls1_2[4]['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($pls1_2[4]['phase']['4-1']) && in_array($pls1_2[4]['phase']['4-1']['phase_e'], [90, 180]))
            )
            {
                $foothold_2_bad -= 1;
            }
        }
        if ($pls2_2[4]['in_house_id'] == 3 || $pls2_2[4]['in_house_id'] == 7)
        {
            if (
                (isset($pls2_2[4]['phase']['4-0']) && in_array($pls2_2[4]['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($pls2_2[4]['phase']['4-1']) && in_array($pls2_2[4]['phase']['4-1']['phase_e'], [90, 180]))
            )
            {
                $foothold_2_bad -= 1;
            }
        }
        // 土落对方9冲日月-2 土落对方7刑冲日月-2
        if ($pls1_2[6]['in_house_id'] == 9 || $pls1_2[6]['in_house_id'] == 7)
        {
            if (
                (isset($pls1_2[6]['phase']['4-0']) && in_array($pls1_2[6]['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($pls1_2[6]['phase']['4-1']) && in_array($pls1_2[6]['phase']['4-1']['phase_e'], [90, 180]))
            )
            {
                $foothold_2_bad -= 2;
            }
        }
        if ($pls2_2[6]['in_house_id'] == 9 || $pls2_2[6]['in_house_id'] == 7)
        {
            if (
                (isset($pls2_2[6]['phase']['4-0']) && in_array($pls2_2[6]['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($pls2_2[6]['phase']['4-1']) && in_array($pls2_2[6]['phase']['4-1']['phase_e'], [90, 180]))
            )
            {
                $foothold_2_bad -= 2;
            }
        }

        if ($foothold_2 >= 5 && $foothold_2_bad >= -2)
        {
            $ret[] = '交流顺畅，谈天说地轻松愉悦';
        }
//        p($foothold_2);
//        p($foothold_2_bad);
        ##########################2志趣相投，谈天说地轻松愉悦 END###############################################

        ##########################3心灵相通，相互理解相互抚慰，可以倾诉心事相互信赖 start#########################
        $foothold_3_bad = 0;
        // 月亮互动良好（负分0且正分高于2，或负分低于-2正分高于3.5）
        if (!empty($pls1[1]['phase']))
        {
            foreach ($pls1[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 0 || $ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                {
                    if ($ps['id'] == 0)
                    {
                        $foothold_3 += 2;
                    } elseif ($ps['id'] == 1)
                    {
                        $foothold_3 += 3.5;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 5)
                    {
                        $foothold_3 += 1.5;
                    }
                }
                if ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_3 += 1.5;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_3 += 1.2;
                    }
                }
                if ($ps['id'] == MC && ($ps['phase_e'] == 0 || $ps['phase_e'] == 180))
                {
                    $foothold_3 += 1.2;

                }
            }
        }
        if (!empty($pls2[1]['phase']))
        {
            foreach ($pls2[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 0 || $ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                {
                    // 前面月-月计算过  此处不计算
                    if ($ps['id'] == 0)
                    {
                        $foothold_3 += 2;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 5)
                    {
                        $foothold_3 += 1.5;
                    }
                }
                if ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_3 += 1.5;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_3 += 1.2;
                    }
                }
                if ($ps['id'] == MC && ($ps['phase_e'] == 0 || $ps['phase_e'] == 180))
                {
                    $foothold_3 += 1.2;

                }
            }
        }
        // 月亮冲太阳+1（若合盘存在月土月火月天月海月月刑冲则改为+0.5）
        if (
            (isset($pls1[1]['phase']['1-0']) && $pls1[1]['phase']['1-0']['phase_e'] == 180)
            ||
            (isset($pls2[1]['phase']['1-0']) && $pls2[1]['phase']['1-0']['phase_e'] == 180)
        )
        {
            if (
                (
                    !isset($pls1[1]['phase']['1-1']) || !in_array($pls1[1]['phase']['1-1']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls1[1]['phase']['1-4']) || !in_array($pls1[1]['phase']['1-4']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls1[1]['phase']['1-6']) || !in_array($pls1[1]['phase']['1-6']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls1[1]['phase']['1-7']) || !in_array($pls1[1]['phase']['1-7']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls1[1]['phase']['1-8']) || !in_array($pls1[1]['phase']['1-8']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls2[1]['phase']['1-4']) || !in_array($pls2[1]['phase']['1-4']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls2[1]['phase']['1-6']) || !in_array($pls2[1]['phase']['1-6']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls2[1]['phase']['1-7']) || !in_array($pls2[1]['phase']['1-7']['phase_e'], [90, 180])
                )
                ||
                (
                    !isset($pls2[1]['phase']['1-8']) || !in_array($pls2[1]['phase']['1-8']['phase_e'], [90, 180])
                )
            )
            {
                $foothold_3 += 0.5;
            } else
            {
                $foothold_3 += 1;
            }
        }
        // 月亮在同一星座但不成合相+1
        if ($pls1[1]['in_sign_id'] == $pls1_2[1]['in_sign_id']
            &&
            (
                !isset($pls1[1]['phase']['1-1'])
                || $pls1[1]['phase']['1-1']['phase_e'] != 0
            )
        )
        {
            $foothold_3 += 1;
        }
        // 月土刑冲-2
        if (isset($pls1[1]['phase']['1-6']) && in_array($pls1[1]['phase']['1-6']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 2;
        }
        if (isset($pls2[1]['phase']['1-6']) && in_array($pls2[1]['phase']['1-6']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 2;
        }
        // 月土合-1（若合土星的月亮无其它刑冲，并与对方日月金木成合拱六分，改为-0.5）
        if (isset($pls1[1]['phase']['1-6']) && $pls1[1]['phase']['1-6']['phase_e'] == 0)
        {
            $f3_1_90180 = false;
            $f3_1_060120 = false;
            foreach ($pls1[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    $f3_1_90180 = true;
                } elseif (
                    in_array($ps['id'], [0, 1, 3, 5]) && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $f3_1_060120 = true;
                }
            }
            if ($f3_1_90180 === false && $f3_1_060120)
            {
                $foothold_3_bad -= 0.5;
            } else
            {
                $foothold_3_bad -= 1;
            }
        }
        if (isset($pls2[1]['phase']['1-6']) && $pls2[1]['phase']['1-6']['phase_e'] == 0)
        {
            $f3_1_90180 = false;
            $f3_1_060120 = false;
            foreach ($pls2[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    $f3_1_90180 = true;
                } elseif (
                    in_array($ps['id'], [0, 1, 3, 5]) && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $f3_1_060120 = true;
                }
            }
            if ($f3_1_90180 === false && $f3_1_060120)
            {
                $foothold_3_bad -= 0.5;
            } else
            {
                $foothold_3_bad -= 1;
            }
        }
        // 月火刑冲-2
        if (isset($pls1[1]['phase']['1-4']) && in_array($pls1[1]['phase']['1-4']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1.5;
        }
        if (isset($pls2[1]['phase']['1-4']) && in_array($pls2[1]['phase']['1-4']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1.5;
        }
        // 月火合-0.5 （若合火星的月亮无其它刑冲，并与对方日月金木成合拱六分，此条无效）
        if (isset($pls1[1]['phase']['1-4']) && $pls1[1]['phase']['1-4']['phase_e'] == 0)
        {
            $f3_1_90180 = false;
            $f3_1_060120 = false;
            foreach ($pls1[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    $f3_1_90180 = true;
                } elseif (
                    in_array($ps['id'], [0, 1, 3, 5]) && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $f3_1_060120 = true;
                }
            }
            if (!$f3_1_90180 === false || !$f3_1_060120)
            {
                $foothold_3_bad -= 0.5;
            }
        }
        if (isset($pls2[1]['phase']['1-4']) && $pls2[1]['phase']['1-4']['phase_e'] == 0)
        {
            $f3_1_90180 = false;
            $f3_1_060120 = false;
            foreach ($pls2[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                {
                    $f3_1_90180 = true;
                } elseif (
                    in_array($ps['id'], [0, 1, 3, 5]) && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $f3_1_060120 = true;
                }
            }
            if (!$f3_1_90180 === false || !$f3_1_060120)
            {
                $foothold_3_bad -= 0.5;
            }
        }
        // 月月刑冲
        if (isset($pls1[1]['phase']['1-1']))
        {
            if ($pls1[1]['phase']['1-1']['phase_e'] == 90)
            {
                $foothold_3_bad -= 2;
            } elseif ($pls1[1]['phase']['1-1']['phase_e'] == 180)
            {
                $foothold_3_bad -= 1;
            }
        }
        // 月天刑冲-1.5
        if (isset($pls1[1]['phase']['1-7']) && in_array($pls1[1]['phase']['1-7']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1.5;
        }
        if (isset($pls2[1]['phase']['1-7']) && in_array($pls2[1]['phase']['1-7']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1.5;
        }
        if (isset($pls1[1]['phase']['1-7']) && $pls1[1]['phase']['1-7']['phase_e'] == 0)
        {
            $foothold_3_bad -= 1;
        }
        if (isset($pls2[1]['phase']['1-7']) && $pls2[1]['phase']['1-7']['phase_e'] == 0)
        {
            $foothold_3_bad -= 1;
        }
        // 月海刑冲-2
        if (isset($pls1[1]['phase']['1-8']) && in_array($pls1[1]['phase']['1-8']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1;
        }
        if (isset($pls2[1]['phase']['1-8']) && in_array($pls2[1]['phase']['1-8']['phase_e'], [90, 180]))
        {
            $foothold_3_bad -= 1;
        }

        // 天王星合上升或下降且 金月不合轴-2（若轴点方本命天王星合升降点，该合盘相位必须比本命相位更加精确，否则无效）
        if (
            isset($pls1[7]['phase']['7-' . ASC])
            && in_array($pls1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
            && $pls1[7]['phase']['7-' . ASC]['phase_orb'] <= 2
            &&
            (
                (!isset($pls1[1]['phase']['1-' . ASC]) || !in_array($pls1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                &&
                (!isset($pls1[1]['phase']['1-' . MC]) || !in_array($pls1[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                &&
                (!isset($pls1[3]['phase']['3-' . ASC]) || !in_array($pls1[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                &&
                (!isset($pls1[3]['phase']['3-' . MC]) || !in_array($pls1[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
            )
        )
        {
            $c = -2;
            $or_orb = $pls1[7]['phase']['7-' . ASC]['phase_orb'];
            $pl_7 = $pls1[7]['deg'];
            $pl_asc = $pls1[7]['deg'];
            $da = abs($pl_7 - $pl_asc);
            if ($da > 180) $da = 360 - $da;
            // 90°相位
            if ($da <= 96 && $da >= 84 && abs($da - 90) <= $or_orb)
            {
                $c = 0;
            }
            if ($da <= 186 && $da >= 174 && abs($da - 180) <= $or_orb)
            {
                $c = 0;
            }
            $foothold_3_bad += $c;
        }
        if (
            isset($pls2[7]['phase']['7-' . ASC])
            && in_array($pls2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
            && $pls2[7]['phase']['7-' . ASC]['phase_orb'] <= 2
            &&
            (
                (!isset($pls2[1]['phase']['1-' . ASC]) || !in_array($pls2[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                &&
                (!isset($pls2[1]['phase']['1-' . MC]) || !in_array($pls2[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                &&
                (!isset($pls2[3]['phase']['3-' . ASC]) || !in_array($pls2[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                &&
                (!isset($pls2[3]['phase']['3-' . MC]) || !in_array($pls2[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
            )
        )
        {
            $c = -2;
            $or_orb = $pls2[7]['phase']['7-' . ASC]['phase_orb'];
            $pl_7 = $pls2[7]['deg'];
            $pl_asc = $pls2[ASC]['deg'];
            $da = abs($pl_7 - $pl_asc);
            if ($da > 180) $da = 360 - $da;
            // 90°相位
            if ($da <= 96 && $da >= 84 && abs($da - 90) <= $or_orb)
            {
                $c = 0;
            }
            if ($da <= 186 && $da >= 174 && abs($da - 180) <= $or_orb)
            {
                $c = 0;
            }
            $foothold_3_bad += $c;
        }
        // 双方月天互相-2 互相成相
        if (isset($pls1[1]['phase']['1-7']) && isset($pls2[1]['phase']['1-7']))
        {
            $foothold_3_bad -= 2;
        }
        if (
            ($foothold_3_bad == 0 && $foothold_3 > 2)
            || ($foothold_3_bad >= -2 && $foothold_3 > 3.5)
        )
        {
            $ret[] = '心灵相通，相互理解相互抚慰，可以倾诉心事相互信赖';
        }
//        p($foothold_3);
//        p($foothold_3_bad);
        ##########################3心灵相通，相互理解相互抚慰，可以倾诉心事相互信赖 END#########################


        ##########################4赠送礼物，提供机会，给予心灵的启示 start##################################
        // 金木（2分以上合格）
        if (!empty($pls1[5]['phase']))
        {
            foreach ($pls1[5]['phase'] as $ps)
            {
                if ($ps['id'] == ASC && in_array($ps['phase_e'], [0, 180]))
                {
                    $foothold_4 += 2;
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 2;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 1.5;
                    }
                } elseif ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 2;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 0.8;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 0.8;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 0.5;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    }
                }
            }
        }
        if (!empty($pls2[5]['phase']))
        {
            foreach ($pls2[5]['phase'] as $ps)
            {
                if ($ps['id'] == ASC && in_array($ps['phase_e'], [0, 180]))
                {
                    $foothold_4 += 2;
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 2;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 1.5;
                    }
                } elseif ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 2;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 0.8;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 0.8;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_4 += 0.5;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_4 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_4 += 1;
                    }
                }
            }
        }
        if ($foothold_4 > 2)
        {
            $ret[] = '有金钱物质方面的往来，或者机会的提供、心灵的启示';
        }
//        p($foothold_4);
        ##########################4赠送礼物，提供机会，给予心灵的启示 END####################################

        ##########################5 4强烈的欲望和男女激情的吸引力 start####################################
        $foothold_5_bad = 0;
        $phase_5_fine_1 = false;
        if (!empty($pls1[4]['phase']))
        {
            foreach ($pls1[4]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 0.5;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 0.5;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 3;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 0.5;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_1 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                } elseif ($ps['id'] == 6)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_5 -= 1.5;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                }
            }
        }
        $house5_pl4_diff_2 = abs($data2['details1']['houses'][5]['deg'] - $pls1[4]['deg']);
        if ($house5_pl4_diff_2 > 180) $house5_pl4_diff_2 = 360 - $house5_pl4_diff_2;
        $house7_pl4_diff_2 = abs($data2['details1']['houses'][7]['deg'] - $pls1[4]['deg']);
        if ($house7_pl4_diff_2 > 180) $house7_pl4_diff_2 = 360 - $house7_pl4_diff_2;
        $house8_pl4_diff_2 = abs($data2['details1']['houses'][8]['deg'] - $pls1[4]['deg']);
        if ($house8_pl4_diff_2 > 180) $house8_pl4_diff_2 = 360 - $house8_pl4_diff_2;
        if ($phase_5_fine_1 === true)
        {
            if (
                $pls2_2[4]['in_house_id'] == 1
                || (isset($pls2_2[4]['phase']['4-' . ASC]) && $pls2_2[4]['phase']['4-' . ASC]['phase_e'] == 0)
            )
            {
                $foothold_5 += 1.5;
            } elseif ($pls2_2[4]['in_house_id'] == 5 || $house5_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            } elseif ($pls2_2[4]['in_house_id'] == 7 || $house7_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            } elseif ($pls2_2[4]['in_house_id'] == 8 || $house8_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            }
        }
        $phase_5_fine_2 = false;
        if (!empty($pls2[4]['phase']))
        {
            foreach ($pls2[4]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 1;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 0.5;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 1.5;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 0.5;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 3;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $phase_5_fine_2 = true;
                        $foothold_5 += 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 0.5;
                    }
                } elseif ($ps['id'] == 6)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_5 -= 1.5;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_5 -= 1;
                    }
                }
            }
        }
        $house5_pl4_diff_1 = abs($data1['details1']['houses'][5]['deg'] - $pls2[4]['deg']);
        if ($house5_pl4_diff_1 > 180) $house5_pl4_diff_2 = 360 - $house5_pl4_diff_2;
        $house7_pl4_diff_1 = abs($data1['details1']['houses'][7]['deg'] - $pls2[4]['deg']);
        if ($house7_pl4_diff_1 > 180) $house7_pl4_diff_2 = 360 - $house7_pl4_diff_2;
        $house8_pl4_diff_1 = abs($data1['details1']['houses'][8]['deg'] - $pls2[4]['deg']);
        if ($house8_pl4_diff_1 > 180) $house8_pl4_diff_2 = 360 - $house8_pl4_diff_2;
        if ($phase_5_fine_2 === true)
        {
            if (
                $pls1_2[4]['in_house_id'] == 1
                || (isset($pls1_2[4]['phase']['4-' . ASC]) && $pls1_2[4]['phase']['4-' . ASC]['phase_e'] == 0)
            )
            {
                $foothold_5 += 1.5;
            } elseif ($pls1_2[4]['in_house_id'] == 5 || $house5_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            } elseif ($pls1_2[4]['in_house_id'] == 7 || $house7_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            } elseif ($pls1_2[4]['in_house_id'] == 8 || $house8_pl4_diff_2 < 6)
            {
                $foothold_5 += 1.5;
            }
        }
        if ($pls1_2[4]['in_house_id'] == 12 || $pls1_2[4]['in_house_id'] == 6 || $pls1_2[4]['in_house_id'] == 2)
        {
            $foothold_5_bad -= 1.5;
        }
        if ($pls2_2[4]['in_house_id'] == 12 || $pls2_2[4]['in_house_id'] == 6 || $pls2_2[4]['in_house_id'] == 2)
        {
            $foothold_5_bad -= 1.5;
        }
        if (empty($pls1_2[4]['phase']) && !in_array($pls1_2[4]['in_house_id'], [1, 5, 7]))
        {
            $foothold_5_bad -= 3;
        }
        if (empty($pls2_2[4]['phase']) && !in_array($pls2_2[4]['in_house_id'], [1, 5, 7]))
        {
            $foothold_5_bad -= 3;
        }
        if ($foothold_5 > 2.5)
        {
            $ret[] = '如果性向符合的话，容易引发强烈的欲望和男女激情的吸引力';
        }
//        p($foothold_5);
        ##########################5 4强烈的欲望和男女激情的吸引力 END####################################

        #####6 5责任与约束，一方以前辈或上级的身份面对另一方，有时传授经验，教另一方成长或相互督促成长 start########
        $foothold_6_bad = 0;
        if (!empty($pls1[6]['phase']))
        {
            foreach ($pls1[6]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_6 += 1.5;
                        if (
                            isset($pls1[5]['phase']['5-0'])
                            && in_array($pls1[5]['phase']['5-0']['phase_e'], [0, 60, 120])
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 0.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_6 += 1;
                        if (
                            isset($pls1[5]['phase']['5-0'])
                            && in_array($pls1[5]['phase']['5-0']['phase_e'], [0, 60, 120, 180])
                        )
                        {
                            $foothold_6 += 1;
                        }
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_6 += 1;
                        if (
                            isset($pls1[5]['phase']['5-0'])
                            && in_array($pls1[5]['phase']['5-0']['phase_e'], [0, 60, 120])
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 2;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_6 += 2;
                        if (
                            (
                                isset($pls1[0]['phase']['0-1'])
                                && in_array($pls1[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls1[5]['phase']['5-1'])
                                && in_array($pls1[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 0.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_6 += 1.5;
                        if (
                            (
                                isset($pls1[0]['phase']['0-1'])
                                && in_array($pls1[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls1[5]['phase']['5-1'])
                                && in_array($pls1[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_6 += 1.5;
                        if (
                            (
                                isset($pls1[0]['phase']['0-1'])
                                && in_array($pls1[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls1[5]['phase']['5-1'])
                                && in_array($pls1[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_6 -= 1;
                        $foothold_6_bad -= 2;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == IC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == DES)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                }
            }
            if (
                isset($pls1[6]['phase']['6-0'])
                && in_array($pls1[6]['phase']['6-0']['phase_e'], [0, 90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls1[6]['phase']['6-1'])
                && in_array($pls1[6]['phase']['6-1']['phase_e'], [0, 90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls1[6]['phase']['6-2'])
                && in_array($pls1[6]['phase']['6-2']['phase_e'], [90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls1[6]['phase']['6-3'])
                && in_array($pls1[6]['phase']['6-3']['phase_e'], [90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
        }

        if (!empty($pls2[6]['phase']))
        {
            foreach ($pls2[6]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_6 += 1.5;
                        if (
                            isset($pls2[5]['phase']['5-0'])
                            && in_array($pls2[5]['phase']['5-0']['phase_e'], [0, 60, 120])
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 0.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_6 += 1;
                        if (
                            isset($pls2[5]['phase']['5-0'])
                            && in_array($pls2[5]['phase']['5-0']['phase_e'], [0, 60, 120, 180])
                        )
                        {
                            $foothold_6 += 1;
                        }
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_6 += 1;
                        if (
                            isset($pls2[5]['phase']['5-0'])
                            && in_array($pls2[5]['phase']['5-0']['phase_e'], [0, 60, 120])
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 2;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $foothold_6 += 2;
                        if (
                            (
                                isset($pls2[0]['phase']['0-1'])
                                && in_array($pls2[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls2[5]['phase']['5-1'])
                                && in_array($pls2[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 0.5;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $foothold_6 += 1.5;
                        if (
                            (
                                isset($pls2[0]['phase']['0-1'])
                                && in_array($pls2[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls2[5]['phase']['5-1'])
                                && in_array($pls2[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $foothold_6 += 1.5;
                        if (
                            (
                                isset($pls2[0]['phase']['0-1'])
                                && in_array($pls2[0]['phase']['0-1']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls2[5]['phase']['5-1'])
                                && in_array($pls2[5]['phase']['5-1']['phase_e'], [0, 60, 120])
                            )
                        )
                        {
                            $foothold_6 += 1;
                        }
                        $foothold_6_bad -= 2;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $foothold_6 -= 1;
                        $foothold_6_bad -= 2;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == IC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == DES)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 90)
                    {
                        $foothold_6_bad -= 1;
                    }
                }
            }
            if (
                isset($pls2[6]['phase']['6-0'])
                && in_array($pls2[6]['phase']['6-0']['phase_e'], [0, 90, 180])
            )
            {
                if (isset($pls2[6]['phase']['6-' . ASC])
                    && in_array($pls2[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls2[6]['phase']['6-' . MC])
                    && in_array($pls2[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls2[6]['phase']['6-1'])
                && in_array($pls2[6]['phase']['6-1']['phase_e'], [0, 90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls2[6]['phase']['6-2'])
                && in_array($pls2[6]['phase']['6-2']['phase_e'], [90, 180])
            )
            {
                if (isset($pls1[6]['phase']['6-' . ASC])
                    && in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls1[6]['phase']['6-' . MC])
                    && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
            if (
                isset($pls2[6]['phase']['6-3'])
                && in_array($pls2[6]['phase']['6-3']['phase_e'], [90, 180])
            )
            {
                if (isset($pls2[6]['phase']['6-' . ASC])
                    && in_array($pls2[6]['phase']['6-' . ASC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 1;
                } elseif (isset($pls2[6]['phase']['6-' . MC])
                    && in_array($pls2[6]['phase']['6-' . MC]['phase_e'], [0, 180]))
                {
                    $foothold_6_bad -= 0.5;
                }
            }
        }
        if ($foothold_6 > 2 && $foothold_6_bad + $foothold_6 >= 0)
        {
            $ret[] = '责任与约束，一方以前辈或上级的身份面对另一方，有时传授经验，教另一方成长或相互督促成长';
        }
//        p($foothold_6);
//        p($foothold_6_bad);
        ########6 5责任与约束，一方以前辈或上级的身份面对另一方，有时传授经验，教另一方成长或相互督促成长 END#######

        #############7 6一起经营事业、赚钱，共谋利益，或一方带给另一方物质上的好处 start#####################
        // 日月金木
        foreach ($temp1_1 as $t1_1)
        {
            $p1 = $pls1_2[$t1_1];
            $p2 = $pls2_2[$t1_1];
            $t = [0, 1, 3, 4, 5];
            $countT = count($t);
            if ($p1['in_house_id'] == 2)
            {
                for ($i = 0; $i < $countT; $i++)
                {
                    if ($t1_1 == 5 && $i > 3) continue;
                    if (isset($p1['phase'][$t1_1 . '-' . $t[$i]]))
                    {
                        if (in_array($p1['phase'][$t1_1 . '-' . $t[$i]]['phase_e'], [0, 120]))
                        {
                            $foothold_7 += 2;
                        } elseif ($p1['phase'][$t1_1 . '-' . $t[$i]]['phase_e'] == 60)
                        {
                            $foothold_7 += 1;
                        }
                    }
                    if ($t[$i] == 0 || $t[$i] == 1 || $t[$i] == 3)
                    {
                        if (
                            isset($p1['phase'][$t1_1 . '-' . $t[$i]])
                            && in_array($p1['phase'][$t1_1 . '-' . $t[$i]]['phase_e'], [90, 180])
                        )
                        {
                            $foothold_7 += 1;
                        }
                    }
                }
                if ($t1_1 != 5)
                {
                    if (isset($p1['phase'][$t1_1 . '-4'])
                        && in_array($p1['phase'][$t1_1 . '-4']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 2;
                    }
                    if (isset($p1['phase'][$t1_1 . '-6'])
                        && in_array($p1['phase'][$t1_1 . '-6']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 2;
                    }
                    if (isset($p1['phase'][$t1_1 . '-2'])
                        && in_array($p1['phase'][$t1_1 . '-2']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 1;
                    }
                    if (
                        isset($p1['phase'][$t1_1 . '-8'])
                        && in_array($p1['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                        && $p1['phase'][$t1_1 . '-8']['phase_orb'] < 1
                    )
                    {
                        $foothold_7 -= 1;
                    }
                }
            }
            if ($p2['in_house_id'] == 2)
            {
                for ($i = 0; $i < $countT; $i++)
                {
                    if ($t1_1 == 5 && $i > 3) continue;
                    if (isset($p2['phase'][$t1_1 . '-' . $t[$i]]))
                    {
                        if (in_array($p2['phase'][$t1_1 . '-' . $t[$i]]['phase_e'], [0, 120]))
                        {
                            $foothold_7 += 2;
                        } elseif ($p2['phase'][$t1_1 . '-' . $t[$i]]['phase_e'] == 60)
                        {
                            $foothold_7 += 1;
                        }
                    }
                    if ($t[$i] == 0 || $t[$i] == 1 || $t[$i] == 3)
                    {
                        if (
                            isset($p2['phase'][$t1_1 . '-' . $t[$i]])
                            && in_array($p2['phase'][$t1_1 . '-' . $t[$i]]['phase_e'], [90, 180])
                        )
                        {
                            $foothold_7 += 1;
                        }
                    }
                }
                if ($t1_1 != 5)
                {
                    if (isset($p2['phase'][$t1_1 . '-4'])
                        && in_array($p2['phase'][$t1_1 . '-4']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 2;
                    }
                    if (isset($p2['phase'][$t1_1 . '-6'])
                        && in_array($p2['phase'][$t1_1 . '-6']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 2;
                    }
                    if (isset($p2['phase'][$t1_1 . '-2'])
                        && in_array($p2['phase'][$t1_1 . '-2']['phase_e'], [90, 180]))
                    {
                        $foothold_7 -= 1;
                    }
                    if (
                        isset($p2['phase'][$t1_1 . '-8'])
                        && in_array($p2['phase'][$t1_1 . '-8']['phase_e'], [90, 180])
                        && $p2['phase'][$t1_1 . '-8']['phase_orb'] < 1
                    )
                    {
                        $foothold_7 -= 1;
                    }
                }
            }
        }
        if ($foothold_7 > 2)
        {
            $ret[] = '一起经营事业、赚钱，共谋利益，或一方带给另一方物质上的好处';
        }
//        p($foothold_7);
        #############7 6一起经营事业、赚钱，共谋利益，或一方带给另一方物质上的好处 END####################

        ##########################8 7性情相似、投缘，有默契，容易相互理解 start######################
        if ($pls1[0]['in_sign_id'] == $pls2[0]['in_sign_id'])
        {
            $foothold_8 += 2;
        } else
        {
            if ($pls1[0]['in_sign_id'] % 3 == $pls2[0]['in_sign_id'] % 3)
            {
                $foothold_8 += 1;
            }
        }
        if ($pls1[1]['in_sign_id'] == $pls2[1]['in_sign_id'])
        {
            $foothold_8 += 2;
        } else
        {
            if ($pls1[1]['in_sign_id'] % 3 == $pls2[1]['in_sign_id'] % 3)
            {
                $foothold_8 += 1;
            }
        }
        if ($pls1[0]['in_sign_id'] == $pls2[1]['in_sign_id'])
        {
            $foothold_8 += 2;
        }
        if ($pls1[1]['in_sign_id'] == $pls2[0]['in_sign_id'])
        {
            $foothold_8 += 2;
        }
        if ($pls1[0]['in_sign_id'] == $pls2[ASC]['in_sign_id'])
        {
            $foothold_8 += 1.5;
        }
        if ($pls1[ASC]['in_sign_id'] == $pls2[0]['in_sign_id'])
        {
            $foothold_8 += 1.5;
        }
        if ($pls1[1]['in_sign_id'] == $pls2[ASC]['in_sign_id'])
        {
            $foothold_8 += 1.5;
        }
        if ($pls1[ASC]['in_sign_id'] == $pls2[1]['in_sign_id'])
        {
            $foothold_8 += 1.5;
        }
        if (
            $pls1[0]['in_sign_id'] != $pls2[1]['in_sign_id']
            && $pls1[0]['in_sign_id'] % 3 == $pls2[1]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 1;
        }
        if (
            $pls1[1]['in_sign_id'] != $pls2[0]['in_sign_id']
            && $pls1[1]['in_sign_id'] % 3 == $pls2[0]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 1;
        }
        if (
            $pls1[0]['in_sign_id'] != $pls2[ASC]['in_sign_id']
            && $pls1[0]['in_sign_id'] % 3 == $pls2[ASC]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 0.5;
        }
        if (
            $pls1[ASC]['in_sign_id'] != $pls2[0]['in_sign_id']
            && $pls1[ASC]['in_sign_id'] % 3 == $pls2[0]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 0.5;
        }
        if (
            $pls1[ASC]['in_sign_id'] != $pls2[1]['in_sign_id']
            && $pls1[ASC]['in_sign_id'] % 3 == $pls2[1]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 0.5;
        }
        if (
            $pls1[1]['in_sign_id'] != $pls2[ASC]['in_sign_id']
            && $pls1[1]['in_sign_id'] % 3 == $pls2[ASC]['in_sign_id'] % 3
        )
        {
            $foothold_8 += 0.5;
        }
        if ($foothold_8 > 3)
        {
            $ret[] = '性情相似、投缘，有默契，容易相互理解';
        }
//        p($foothold_8);
        ##########################8 7性情相似、投缘，有默契，容易相互理解 END##################

        #######9 8基于舒适轻松的相处，双方共同的圈子或者有相互合作的意愿，有时会牵涉到物质利益 start##########
        // 双方月亮无日月金木的合拱六分，也无日月火土的刑相位，此时双方金星均与对方日水金成非刑相且无火土刑冲相+2
        if (
            (
                !isset($pls1[1]['phase']['1-0'])
                || in_array($pls1[1]['phase']['1-0']['phase_e'], [0, 60, 120, 90])
            )
            &&
            (
                !isset($pls1[1]['phase']['1-1'])
                || in_array($pls1[1]['phase']['1-1']['phase_e'], [0, 60, 120, 90])
            )
            &&
            (
                !isset($pls1[1]['phase']['1-3'])
                || in_array($pls1[1]['phase']['1-3']['phase_e'], [0, 60, 120])
            )
            &&
            (
                !isset($pls1[1]['phase']['1-5'])
                || in_array($pls1[1]['phase']['1-5']['phase_e'], [0, 60, 120])
            )
            &&
            (
                !isset($pls1[1]['phase']['1-4'])
                || $pls1[1]['phase']['1-4']['phase_e'] != 90
            )
            &&
            (
                !isset($pls1[1]['phase']['1-6'])
                || $pls1[1]['phase']['1-6']['phase_e'] != 90
            )
            &&
            (
                !isset($pls2[1]['phase']['1-0'])
                || in_array($pls2[1]['phase']['1-0']['phase_e'], [0, 60, 120, 90])
            )
            &&
            (
                !isset($pls2[1]['phase']['1-3'])
                || in_array($pls2[1]['phase']['1-3']['phase_e'], [0, 60, 120])
            )
            &&
            (
                !isset($pls2[1]['phase']['1-5'])
                || in_array($pls2[1]['phase']['1-5']['phase_e'], [0, 60, 120])
            )
            &&
            (
                !isset($pls2[1]['phase']['1-4'])
                || $pls2[1]['phase']['1-4']['phase_e'] != 90
            )
            &&
            (
                !isset($pls2[1]['phase']['1-6'])
                || $pls2[1]['phase']['1-6']['phase_e'] != 90
            )
            &&
            (
                isset($pls1[3]['phase']['3-0'])
                && $pls1[3]['phase']['3-0']['phase_e'] != 90
            )
            &&
            (
                isset($pls1[3]['phase']['3-2'])
                && $pls1[3]['phase']['3-2']['phase_e'] != 90
            )
            &&
            (
                isset($pls1[3]['phase']['3-3'])
                && $pls1[3]['phase']['3-3']['phase_e'] != 90
            )
            &&
            (
                isset($pls1[3]['phase']['3-4'])
                && !in_array($pls1[3]['phase']['3-4']['phase_e'], [90, 180])
            )
            &&
            (
                isset($pls2[3]['phase']['3-6'])
                && !in_array($pls2[3]['phase']['3-6']['phase_e'], [90, 180])
            )
            &&
            (
                isset($pls2[3]['phase']['3-0'])
                && $pls2[3]['phase']['3-0']['phase_e'] != 90
            )
            &&
            (
                isset($pls2[3]['phase']['3-2'])
                && $pls2[3]['phase']['3-2']['phase_e'] != 90
            )
            &&
            (
                isset($pls2[3]['phase']['3-4'])
                && !in_array($pls2[3]['phase']['3-4']['phase_e'], [90, 180])
            )
            &&
            (
                isset($pls2[3]['phase']['3-6'])
                && !in_array($pls2[3]['phase']['3-6']['phase_e'], [90, 180])
            )
        )
        {
            $foothold_9 += 2;
        }
        if ($foothold_9 >= 2)
        {
            $ret[] = '基于舒适轻松的相处，双方共同的圈子或者有相互合作的意愿，有时会牵涉到物质利益';
        }
//        p($foothold_9);
        #######9 8基于舒适轻松的相处，双方共同的圈子或者有相互合作的意愿，有时会牵涉到物质利益 END############

        ########10 基于某个瞬间的情感触动或欲望萌生，突然来电，其中可能有距离阻挡，或彼此不够了解 start##########
        if (
            (
                (
                    isset($pls1[7]['phase']['7-1']) && $pls1[7]['phase']['7-1']['phase_e'] != 90
                )
                ||
                (
                    isset($pls1[7]['phase']['7-3']) && $pls1[7]['phase']['7-3']['phase_e'] != 90
                )
                ||
                (
                    isset($pls1[7]['phase']['7-' . ASC])
                    && in_array($pls1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
            )
            &&
            (
                (
                    isset($pls2[7]['phase']['7-1']) && $pls2[7]['phase']['7-1']['phase_e'] != 90
                )
                ||
                (
                    isset($pls2[7]['phase']['7-3']) && $pls2[7]['phase']['7-3']['phase_e'] != 90
                )
                ||
                (
                    isset($pls2[7]['phase']['7-' . ASC])
                    && in_array($pls2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
            )
            &&
            (
                (
                    (isset($pls1[3]['phase']['3-4']) && $pls1[3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($pls1[1]['phase']['1-4']) && $pls1[1]['phase']['1-4']['phase_e'] != 90)
                )
                ||
                (
                    (isset($pls2[3]['phase']['3-4']) && $pls2[3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($pls2[1]['phase']['1-4']) && $pls2[1]['phase']['1-4']['phase_e'] != 90)
                )
            )
        )
        {
            $foothold_10 += 2;
        }

        if ($foothold_10 >= 2)
        {
            $ret[] = '基于某个瞬间的情感触动或欲望萌生，突然来电，其中可能有距离阻挡，或彼此不够了解';
        }
//        p($foothold_10);
        ########10 基于某个瞬间的情感触动或欲望萌生，突然来电，其中可能有距离阻挡，或彼此不够了解 END############

        ############11 9对方带来新奇感，甚至是异常强烈的吸引力，并在磨合中产生刺激的火花。 start##########
        $phase_180_0134_num = 0;
        $phase_180_2_num = 0;
        for ($j = 0; $j < 5; $j++)
        {
            if (isset($pls1[2]['phase']['2-' . $j])
                && $pls1[2]['phase']['2-' . $j]['phase_e'] == 180)
            {
                $phase_180_2_num++;
            }
            if (isset($pls2[2]['phase']['2-' . $j])
                && $pls2[2]['phase']['2-' . $j]['phase_e'] == 180 && 2 != $j)
            {
                $phase_180_2_num++;
            }
        }
        if (isset($pls1[0]['phase']['0-1'])
            && $pls1[0]['phase']['0-1']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls1[0]['phase']['0-3'])
            && $pls1[0]['phase']['0-3']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls1[1]['phase']['1-3'])
            && $pls1[1]['phase']['1-3']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls1[1]['phase']['1-4'])
            && $pls1[1]['phase']['1-4']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls1[4]['phase']['4-4'])
            && $pls1[4]['phase']['4-4']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls2[0]['phase']['0-1'])
            && $pls2[0]['phase']['0-1']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls2[0]['phase']['0-3'])
            && $pls2[0]['phase']['0-3']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls2[1]['phase']['1-3'])
            && $pls2[1]['phase']['1-3']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if (isset($pls2[1]['phase']['1-4'])
            && $pls2[1]['phase']['1-4']['phase_e'] == 180)
        {
            $phase_180_0134_num++;
        }
        if ($phase_180_0134_num >= 2 && $phase_180_2_num >= 1)
        {
            $foothold_11 += 2;
        }

        if (
            (
                (
                    isset($pls1[7]['phase']['7-1'])
                    && in_array($pls1[7]['phase']['7-1']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls1[7]['phase']['7-3'])
                    && in_array($pls1[7]['phase']['7-3']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls1[7]['phase']['7-' . ASC])
                    && in_array($pls1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
            )
            &&
            (
                (
                    isset($pls2[7]['phase']['7-1'])
                    && in_array($pls2[7]['phase']['7-1']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls2[7]['phase']['7-3'])
                    && in_array($pls2[7]['phase']['7-3']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls2[7]['phase']['7-' . ASC])
                    && in_array($pls2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
            )
            &&
            (
                (
                    (isset($pls1[3]['phase']['3-4']) && $pls1[3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($pls1[1]['phase']['1-4']) && $pls1[1]['phase']['1-4']['phase_e'] != 90)
                )
                ||
                (
                    (isset($pls2[3]['phase']['3-4']) && $pls2[3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($pls2[1]['phase']['1-4']) && $pls2[1]['phase']['1-4']['phase_e'] != 90)
                )
            )
        )
        {
            $foothold_11 += 2;
        }
        if ($foothold_11 >= 2)
        {
            $ret[] = '对方带来新奇感，甚至是异常强烈的吸引力，并在磨合中产生刺激的火花';
        }
        ############11 9对方带来新奇感，甚至是异常强烈的吸引力，并在磨合中产生刺激的火花。 END############

        #################12 有共同的兴趣和爱好，一起玩耍，一起寻欢作乐 start#######################
        $f12_01345 = [0, 1, 3, 4, 5];// 日月木金火
        if ($pls1_2[0]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls1_2[0]['phase']['0-' . $f]))
                {
                    if ($pls1_2[0]['phase']['0-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls1_2[0]['phase']['0-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        if ($pls1_2[1]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls1_2[1]['phase']['1-' . $f]))
                {
                    if ($pls1_2[1]['phase']['1-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls1_2[1]['phase']['1-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        if ($pls1_2[3]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls1_2[3]['phase']['3-' . $f]))
                {
                    if ($pls1_2[3]['phase']['3-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls1_2[3]['phase']['3-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        if ($pls2_2[0]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls2_2[0]['phase']['0-' . $f]))
                {
                    if ($pls2_2[0]['phase']['0-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls2_2[0]['phase']['0-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        if ($pls2_2[1]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls2_2[1]['phase']['1-' . $f]))
                {
                    if ($pls2_2[1]['phase']['1-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls2_2[1]['phase']['1-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        if ($pls2_2[3]['in_house_id'] == 5)
        {
            $f12_0_0 = false;
            $f12_0_60 = false;
            foreach ($f12_01345 as $f)
            {
                if (isset($pls2_2[3]['phase']['3-' . $f]))
                {
                    if ($pls2_2[3]['phase']['3-' . $f]['phase_e'] == 0)
                    {
                        $f12_0_0 = true;
                    } elseif (in_array($pls2_2[3]['phase']['3-' . $f]['phase_e'], [60, 120]))
                    {
                        $f12_0_60 = true;
                    }
                }
            }
            if ($f12_0_0)
            {
                $foothold_12 += 2.5;
            }
            if ($f12_0_60)
            {
                $foothold_12 += 2;
            }
        }
        // 若双方金星互刑或双方金星都与对方日月之一刑克-3
        if ((isset($pls1[3]['phase']['3-3']) && $pls1[3]['phase']['3-3']['phase_e'] == 90)
            ||
            (
                (
                    (
                        isset($pls1[3]['phase']['3-0'])
                        && in_array($pls1[3]['phase']['3-0']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-1'])
                        && in_array($pls1[3]['phase']['3-1']['phase_e'], [90, 180])
                    )
                )
                &&
                (
                    (
                        isset($pls2[3]['phase']['3-0'])
                        && in_array($pls2[3]['phase']['3-0']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-1'])
                        && in_array($pls2[3]['phase']['3-1']['phase_e'], [90, 180])
                    )
                )
            )
        )
        {
            $foothold_12 -= 3;
        }
        // 其中一颗金星与对方日月土之一刑-1.5
        if ((((isset($pls1[3]['phase']['3-0']) && $pls1[3]['phase']['3-0']['phase_e'] == 90)
                    || (isset($pls1[3]['phase']['3-1']) && $pls1[3]['phase']['3-1']['phase_e'] == 90)
                    || (isset($pls1[3]['phase']['3-6']) && $pls1[3]['phase']['3-6']['phase_e'] == 90))
                &&
                (!isset($pls2[3]['phase']['3-0']) || $pls2[3]['phase']['3-0']['phase_e'] != 90)
                && (!isset($pls2[3]['phase']['3-1']) || $pls2[3]['phase']['3-1']['phase_e'] != 90)
                && (!isset($pls2[3]['phase']['3-6']) || $pls2[3]['phase']['3-6']['phase_e'] != 90))
            ||
            (((isset($pls2[3]['phase']['3-0']) && $pls2[3]['phase']['3-0']['phase_e'] == 90)
                    || (isset($pls2[3]['phase']['3-1']) && $pls2[3]['phase']['3-1']['phase_e'] == 90)
                    || (isset($pls2[3]['phase']['3-6']) && $pls2[3]['phase']['3-6']['phase_e'] == 90))
                &&
                (!isset($pls1[3]['phase']['3-0']) || $pls1[3]['phase']['3-0']['phase_e'] != 90)
                && (!isset($pls1[3]['phase']['3-1']) || $pls1[3]['phase']['3-1']['phase_e'] != 90)
                && (!isset($pls1[3]['phase']['3-6']) || $pls1[3]['phase']['3-6']['phase_e'] != 90))
        )
        {
            $foothold_12 -= 1.5;
        }
        if (
            (
                isset($pls1[0]['phase']['0-6'])
                && in_array($pls1[0]['phase']['0-6']['phase_e'], [0, 90, 180])
            )
            ||
            (
                isset($pls1[1]['phase']['1-6'])
                && in_array($pls1[1]['phase']['1-6']['phase_e'], [0, 90, 180])
            )
            ||
            (
                isset($pls2[0]['phase']['0-6'])
                && in_array($pls2[0]['phase']['0-6']['phase_e'], [0, 90, 180])
            )
            ||
            (
                isset($pls2[1]['phase']['1-6'])
                && in_array($pls2[1]['phase']['1-6']['phase_e'], [0, 90, 180])
            )
        )
        {
            $foothold_12 -= 2;
        }

        if ($foothold_12 > 2)
        {
            $ret[] = '有共同的兴趣和爱好，一起玩耍，一起寻欢作乐';
        }
        #################12 有共同的兴趣和爱好，一起玩耍，一起寻欢作乐 END#############

        ##################13 一方对另一方的启迪或鼓舞，信念的共鸣，志同道合 start################
        $f13 = [0, 1, 2, 5];
        foreach ($f13 as $f)
        {
            if (isset($pls1[0]['phase']['0-' . $f]))
            {
                if ($pls1[0]['phase']['0-' . $f]['phase_e'] == 0)
                {
                    if ($f == 0)
                    {
                        $foothold_13 += 2;
                        if (
                            $pls2_2[0]['in_house_id'] == 9
                            || $pls1_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 1;
                        }
                    } elseif ($f == 2)
                    {
                        $foothold_13 += 1;
                        if (
                            $pls2_2[0]['in_house_id'] == 9
                            || $pls1_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 0.5;
                        }
                    } elseif ($f == 5)
                    {
                        $foothold_13 += 1.5;
                    }

                } elseif ($pls1[0]['phase']['0-' . $f]['phase_e'] == 60
                    || $pls1[0]['phase']['0-' . $f]['phase_e'] == 120)
                {
                    if ($f == 0)
                    {
                        if (
                            $pls2_2[0]['in_house_id'] == 9
                            || $pls1_2[0]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 1;
                        }
                    } elseif ($f == 2)
                    {
                        $foothold_13 += 0.8;
                        if (
                            $pls2_2[0]['in_house_id'] == 9
                            || $pls1_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 0.5;
                        }
                    } elseif ($f == 5)
                    {
                        $foothold_13 += 1;
                    }
                } elseif ($pls1[0]['phase']['0-' . $f]['phase_e'] == 90)
                {
                    if ($f == 0)
                    {
                        $foothold_13 -= 5;
                    } elseif ($f == 1)
                    {
                        $foothold_13 -= 4;
                    }
                }
            }
            if (isset($pls2[0]['phase']['0-' . $f]))
            {
                if ($pls2[0]['phase']['0-' . $f]['phase_e'] == 0)
                {
                    if ($f == 0)
                    {
                        $foothold_13 += 2;
                        if (
                            $pls1_2[0]['in_house_id'] == 9
                            || $pls2_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 1;
                        }
                    } elseif ($f == 2)
                    {
                        $foothold_13 += 1;
                        if (
                            $pls1_2[0]['in_house_id'] == 9
                            || $pls2_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 0.5;
                        }
                    } elseif ($f == 5)
                    {
                        $foothold_13 += 1.5;
                    }
                } elseif ($pls2[0]['phase']['0-' . $f]['phase_e'] == 60
                    || $pls2[0]['phase']['0-' . $f]['phase_e'] == 120)
                {
                    if ($f == 0)
                    {
                        if (
                            $pls1_2[0]['in_house_id'] == 9
                            || $pls2_2[0]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 1;
                        }
                    } elseif ($f == 2)
                    {
                        $foothold_13 += 0.8;
                        if (
                            $pls1_2[0]['in_house_id'] == 9
                            || $pls2_2[$f]['in_house_id'] == 9
                        )
                        {
                            $foothold_13 += 0.5;
                        }
                    } elseif ($f == 5)
                    {
                        $foothold_13 += 1;
                    }
                } elseif ($pls2[0]['phase']['0-' . $f]['phase_e'] == 90)
                {
                    if ($f == 0)
                    {
                        $foothold_13 -= 5;
                    } elseif ($f == 1)
                    {
                        $foothold_13 -= 4;
                    }
                }
            }
        }
        if ($foothold_13 >= 2)
        {
            $ret[] = '一方对另一方的启迪或鼓舞，信念的共鸣，志同道合';
        }
//        p($foothold_13);
        ##################13 一方对另一方的启迪或鼓舞，信念的共鸣，志同道合 END################

        ######################14 偏偏喜欢你，爱情的无上魔力 start####################################
        $inhouse_57_01_num = 0;
        if ($pls1[0]['in_house_id'] == 5 || $pls1[0]['in_house_id'] == 7) $inhouse_57_01_num++;
        if ($pls1[1]['in_house_id'] == 5 || $pls1[1]['in_house_id'] == 7) $inhouse_57_01_num++;
        if ($pls2[0]['in_house_id'] == 5 || $pls2[0]['in_house_id'] == 7) $inhouse_57_01_num++;
        if ($pls2[1]['in_house_id'] == 5 || $pls2[1]['in_house_id'] == 7) $inhouse_57_01_num++;
        if ($inhouse_57_01_num > 0)
        {
            if (
                isset($pls1[3]['phase']['3-0'])
                || isset($pls1[3]['phase']['3-1'])
                || isset($pls1[3]['phase']['3-3'])
                || isset($pls1[3]['phase']['3-4'])
                || isset($pls2[3]['phase']['3-0'])
                || isset($pls2[3]['phase']['3-1'])
                || isset($pls2[3]['phase']['3-4'])
            )
            {
                $foothold_14 += 1;

                $foothold_14 += ($inhouse_57_01_num - 1);
            }
        }
        if (
            (
                in_array($pls1_2[3]['in_house_id'], [1, 5, 7])
                &&
                (
                    (isset($pls1_2[3]['phase']['3-0'])
                        && in_array($pls1_2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                    || (isset($pls1_2[3]['phase']['3-1'])
                        && in_array($pls1_2[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
                    || (isset($pls1_2[3]['phase']['3-3'])
                        && in_array($pls1_2[3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                    || (isset($pls1_2[3]['phase']['3-4'])
                        && in_array($pls1_2[3]['phase']['3-4']['phase_e'], [0, 60, 120]))
                )
            )
            ||
            (
                in_array($pls2_2[3]['in_house_id'], [1, 5, 7])
                &&
                (
                    (isset($pls2_2[3]['phase']['3-0'])
                        && in_array($pls2_2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                    || (isset($pls2_2[3]['phase']['3-1'])
                        && in_array($pls2_2[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
                    || (isset($pls2_2[3]['phase']['3-3'])
                        && in_array($pls2_2[3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                    || (isset($pls2_2[3]['phase']['3-4'])
                        && in_array($pls2_2[3]['phase']['3-4']['phase_e'], [0, 60, 120]))
                )
            )
        )
        {
            $foothold_14 += 1;
        }
        if ($attract >= 50 && $passion > 50)
        {
            $foothold_14 += 1;
            $foothold_14 += floor(($passion - 50) / 10);
        }
        if ($foothold_14 >= 2 && (($attract + $passion + $benefit) > 90 && ($attract > 40 || $passion > 40 || $benefit > 40)))
        {
            $ret[] = '偏偏喜欢你，臣服于爱情的无上魔力';
        }
//        p($foothold_14);
        ######################14 偏偏喜欢你，爱情的无上魔力 END####################################

        ######################15 宿命的缘分，轮回的因果 start####################################
        if (isset($pls1[12]) && !empty($pls1[12]['phase']))
        {
            foreach ($pls1[12]['phase'] as $ps)
            {
                // 南北交合相
                if ($ps['phase_orb'] <= 2 && ($ps['phase_e'] == 0 || $ps['phase_e'] == 180))
                {
                    if ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == ASC || $ps['id'] == MC)
                    {
                        $foothold_15 += 2;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                    {
                        $foothold_15 += 1;
                    }
                } // 南北交拱相
                elseif ($ps['phase_orb'] <= 2 && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120))
                {
                    if ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == ASC || $ps['id'] == MC)
                    {
                        $foothold_15 += 0.6;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                    {
                        $foothold_15 += 0.3;
                    }
                }
            }
        }
        if (isset($pls2[12]) && !empty($pls2[12]['phase']))
        {
            foreach ($pls2[12]['phase'] as $ps)
            {
                // 南北交合相
                if ($ps['phase_orb'] <= 2 && ($ps['phase_e'] == 0 || $ps['phase_e'] == 180))
                {
                    if ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == ASC || $ps['id'] == MC)
                    {
                        $foothold_15 += 2;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                    {
                        $foothold_15 += 1;
                    }
                } // 南北交拱相
                elseif ($ps['phase_orb'] <= 2 && ($ps['phase_e'] == 60 || $ps['phase_e'] == 120))
                {
                    if ($ps['id'] == 0 || $ps['id'] == 1 || $ps['id'] == ASC || $ps['id'] == MC)
                    {
                        $foothold_15 += 0.6;
                    } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                    {
                        $foothold_15 += 0.3;
                    }
                }
            }
        }
        if ($foothold_15 >= 2)
        {
            $ret[] = '你们的相识是宿命的缘分，轮回的因果';
        }
//        p($foothold_15);
        ######################15 宿命的缘分，轮回的因果 END####################################

        ######################16 冥冥之中，说不清道不明的缘分 start####################################
        if (empty($ret))
        {
            $ret[] = '冥冥之中，有着说不清道不明的缘分';
        }
//        p($ret);
        ######################16 冥冥之中，说不清道不明的缘分 END####################################


        #-----------------------------------------------------------------------------------------#
        #--------------------------------------矛盾点----------------------------------------------#
        #--------------------------------------矛盾点----------------------------------------------#
        #-----------------------------------------------------------------------------------------#
        $conflict_1 = $conflict_2 = $conflict_3 = $conflict_4
            = $conflict_5 = $conflict_6 = $conflict_7 = $conflict_8
            = $conflict_9 = $conflict_10 = $conflict_11 = $conflict_12
            = $conflict_13 = 0;
        $ret2 = [];
        ##########################1 1事业上的矛盾、拖累或工作目标的相互抵触 start#############################
        for ($i = 0; $i < 5; $i++)
        {
            if ($pls1[$i]['in_house_id'] == 6 || $pls1[$i]['in_house_id'] == 10)
            {
                // 日月刑
                if (
                    (isset($pls1[$i]['phase'][$i . '-0'])
                        && $pls1[$i]['phase'][$i . '-0']['phase_e'] == 90)
                    || (isset($pls1[$i]['phase'][$i . '-1'])
                        && $pls1[$i]['phase'][$i . '-1']['phase_e'] == 90)
                )
                {
                    $conflict_1 += 1.5;
                }
                // 水天刑冲
                if (
                    (isset($pls1[$i]['phase'][$i . '-2'])
                        && in_array($pls1[$i]['phase'][$i . '-2']['phase_e'], [90, 180]))
                    || (isset($pls1[$i]['phase'][$i . '-7'])
                        && in_array($pls1[$i]['phase'][$i . '-7']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 0.5;
                }
                // 火土刑冲
                if (
                    (isset($pls1[$i]['phase'][$i . '-4'])
                        && in_array($pls1[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                    || (isset($pls1[$i]['phase'][$i . '-6'])
                        && in_array($pls1[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 2;
                }
                // 土海合
                if (
                    (isset($pls1[$i]['phase'][$i . '-6'])
                        && $pls1[$i]['phase'][$i . '-6']['phase_e'] == 0)
                    || (isset($pls1[$i]['phase'][$i . '-8'])
                        && $pls1[$i]['phase'][$i . '-8']['phase_e'] == 0)
                )
                {
                    $conflict_1 += 0.5;
                }
                // 海冥刑冲
                if (
                    (isset($pls1[$i]['phase'][$i . '-8'])
                        && in_array($pls1[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    || (isset($pls1[$i]['phase'][$i . '-9'])
                        && in_array($pls1[$i]['phase'][$i . '-9']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 1;
                }
            }
            if ($pls1_2[$i]['in_house_id'] == 6 || $pls1_2[$i]['in_house_id'] == 10)
            {
                // 日月刑
                if (
                    (isset($pls1_2[$i]['phase'][$i . '-0'])
                        && $pls1_2[$i]['phase'][$i . '-0']['phase_e'] == 90)
                    || (isset($pls1_2[$i]['phase'][$i . '-1'])
                        && $pls1_2[$i]['phase'][$i . '-1']['phase_e'] == 90)
                )
                {
                    $conflict_1 += 1.5;
                }
                // 水天刑冲
                if (
                    (isset($pls1_2[$i]['phase'][$i . '-2'])
                        && in_array($pls1_2[$i]['phase'][$i . '-2']['phase_e'], [90, 180]))
                    || (isset($pls1_2[$i]['phase'][$i . '-7'])
                        && in_array($pls1_2[$i]['phase'][$i . '-7']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 0.5;
                }
                // 火土刑冲
                if (
                    (isset($pls1_2[$i]['phase'][$i . '-4'])
                        && in_array($pls1_2[$i]['phase'][$i . '-4']['phase_e'], [90, 180]))
                    || (isset($pls1_2[$i]['phase'][$i . '-6'])
                        && in_array($pls1_2[$i]['phase'][$i . '-6']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 2;
                }
                // 土海合
                if (
                    (isset($pls1_2[$i]['phase'][$i . '-6'])
                        && $pls1_2[$i]['phase'][$i . '-6']['phase_e'] == 0)
                    || (isset($pls1_2[$i]['phase'][$i . '-8'])
                        && $pls1_2[$i]['phase'][$i . '-8']['phase_e'] == 0)
                )
                {
                    $conflict_1 += 0.5;
                }
                // 海冥刑冲
                if (
                    (isset($pls1_2[$i]['phase'][$i . '-8'])
                        && in_array($pls1_2[$i]['phase'][$i . '-8']['phase_e'], [90, 180]))
                    || (isset($pls1_2[$i]['phase'][$i . '-9'])
                        && in_array($pls1_2[$i]['phase'][$i . '-9']['phase_e'], [90, 180]))
                )
                {
                    $conflict_1 += 1;
                }
            }
        }
        if (
            (
                isset($pls1[6]['phase']['6-' . MC])
                && in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 90, 180])
            )
            ||
            (
                isset($pls2[6]['phase']['6-' . MC])
                && in_array($pls2[6]['phase']['6-' . MC]['phase_e'], [0, 90, 180])
            )
        )
        {
            $conflict_1 += 1;
        }
        if ($conflict_1 < $foothold_1 && $foothold_1 < 4)
        {
            $ret2[] = '事业上的矛盾、拖累或工作目标的相互抵触';
        }
//        if($pls1[0]['in_house_id'] == 6 || $pls1[0]['in_house_id'] == 10)
//        {
//            // 日月刑
//            if(
//                (isset($pls1[0]['phase']['0-0']) && $pls1[0]['phase']['0-0']['phase_e'] == 90)
//                || (isset($pls1[0]['phase']['0-1']) && $pls1[0]['phase']['0-1']['phase_e'] == 90)
//            )
//            {
//                $conflict_1 += 1.5;
//            }
//            // 水天刑冲
//            if(
//                (isset($pls1[0]['phase']['0-2']) && in_array($pls1[0]['phase']['0-2']['phase_e'],[90,180]))
//                || (isset($pls1[0]['phase']['0-7']) && in_array($pls1[0]['phase']['0-7']['phase_e'],[90,180]))
//            )
//            {
//                $conflict_1 += 0.5;
//            }
//            // 火土刑冲
//            if(
//                (isset($pls1[0]['phase']['0-4']) && in_array($pls1[0]['phase']['0-4']['phase_e'],[90,180]))
//                || (isset($pls1[0]['phase']['0-6']) && in_array($pls1[0]['phase']['0-6']['phase_e'],[90,180]))
//            )
//            {
//                $conflict_1 += 2;
//            }
//            // 土海合
//            if(
//                (isset($pls1[0]['phase']['0-6']) && $pls1[0]['phase']['0-6']['phase_e'] == 0)
//                || (isset($pls1[0]['phase']['0-8']) && $pls1[0]['phase']['0-8']['phase_e'] == 0)
//            )
//            {
//                $conflict_1 += 0.5;
//            }
//            // 海冥刑冲
//            if(
//                (isset($pls1[0]['phase']['0-8']) && in_array($pls1[0]['phase']['0-8']['phase_e'],[90,180]))
//                || (isset($pls1[0]['phase']['0-9']) && in_array($pls1[0]['phase']['0-9']['phase_e'],[90,180]))
//            )
//            {
//                $conflict_1 += 1;
//            }
//        }
        ##########################1 1事业上的矛盾、拖累或工作目标的相互抵触 END###############################

        ##########################2 2沟通不畅，交流中容易产生误解 start####################
        if ($foothold_2 < 0)
        {
            $ret2[] = '沟通不畅，交流中容易产生误解';
        }
        ##########################2 2沟通不畅，交流中容易产生误解 END####################

        ##########################3 3缺乏心灵相交的默契，没有亲密的感觉 start####################
        if ($foothold_3 <= 1)
        {
            $ret2[] = '缺乏心灵相交的默契，没有亲密的感觉';
        }
        ##########################3 3缺乏心灵相交的默契，没有亲密的感觉 END####################

        ##########################4 3情绪不容易产生共融，有时不好理解对方，甚至产生抵触心理 start####################
        if (
            (
                (
                    in_array($pls1[1]['in_sign_id'], [4, 12])
                    && in_array($pls2[1]['in_sign_id'], [1, 9, 10, 11])
                    &&
                    (
                        $pls2[0]['in_sign_id'] % 4 != 0 && $pls2[ASC]['in_sign_id'] % 4 != 0
                    )
                )
                ||
                (
                    in_array($pls2[1]['in_sign_id'], [4, 12])
                    && in_array($pls1[1]['in_sign_id'], [1, 9, 10, 11])
                    &&
                    (
                        $pls1[0]['in_sign_id'] % 4 != 0 && $pls1[ASC]['in_sign_id'] % 4 != 0
                    )
                )
            )
            ||
            (
                abs($foothold_3) < abs($foothold_3_bad) && abs($foothold_3_bad) > 2
            )
            ||
            (
                isset($pl1[1]['phase']['1-1']) && $pl1[1]['phase']['1-1']['phase_e'] == 180
            )
        )
        {
            $ret2[] = '情绪不容易产生共融，有时不好理解对方，甚至产生抵触心理';
        }
        ##########################4 3情绪不容易产生共融，有时不好理解对方，甚至产生抵触心理 END####################

        ##########################5 4若是恋人，缺乏激情，床事不够和谐，找不到对方身体的正确打开方式 start##############
        if ($foothold_5 == 0 || ((abs($foothold_5_bad) - $foothold_5) > 2 && $foothold_5 <= 2))
        {
            $ret2[] = '若是恋人，缺乏激情，床事不够和谐，找不到对方身体的正确打开方式';
        }
        ##########################5 4若是恋人，缺乏激情，床事不够和谐，找不到对方身体的正确打开方式 END###############

        ##########################6 4吵闹争执较多，甚至会动手打架，若在一起的话有家庭暴力的可能 start####################
        // 火星不良减分超过2，两项绝对值之和超过3
        if (abs($foothold_5_bad) < 2 && abs($foothold_5_bad) + $foothold_5 > 3)
        {
            if (
                (
                    isset($pls1[4]['phase']['4-7']) && isset($pls2[4]['phase']['4-7'])
                )
                ||
                (
                    isset($pls1[4]['phase']['4-9']) && isset($pls2[4]['phase']['4-9'])
                )
                ||
                (
                    $pls1[4]['in_sign_id'] % 4 == 1 && $pls2[4]['in_sign_id'] % 4 == 1
                )
                ||
                (
                    $pls1[4]['in_sign_id'] == 2 && $pls2[4]['in_sign_id'] == 2
                )
                ||
                (
                    $pls1[4]['in_sign_id'] == 8 && $pls2[4]['in_sign_id'] == 8
                )
                ||
                (
                    in_array($pls1[4]['in_sign_id'], [4, 12]) && in_array($pls2[4]['in_sign_id'], [4, 12])
                )
            )
            {
                $ret2[] = '吵闹争执较多，甚至会动手打架，若在一起的话有家庭暴力的可能';
            }
        }
        ##########################6 4吵闹争执较多，甚至会动手打架，若在一起的话有家庭暴力的可能 END####################

        ##########################7 5过于冷淡、理性或教条，一方可能要求太多，给对方带来过重的压力 start###########
        if (
            abs($foothold_6_bad) > 3
            ||
            (
                (isset($pls1[6]['phase']['6-0'])
                    && in_array($pls1[6]['phase']['6-0']['phase_e'], [90, 180])
                    && $pls1[6]['phase']['6-0']['phase_orb'] < 4)
                || (isset($pls1[6]['phase']['6-1'])
                    && in_array($pls1[6]['phase']['6-1']['phase_e'], [90, 180])
                    && $pls1[6]['phase']['6-1']['phase_orb'] < 4)
                || (isset($pls2[6]['phase']['6-0'])
                    && in_array($pls2[6]['phase']['6-0']['phase_e'], [90, 180])
                    && $pls2[6]['phase']['6-0']['phase_orb'] < 4)
                || (isset($pls2[6]['phase']['6-1'])
                    && in_array($pls2[6]['phase']['6-1']['phase_e'], [90, 180])
                    && $pls2[6]['phase']['6-1']['phase_orb'] < 4)
            )
        )
        {
            $ret2[] = '过于冷淡、理性或教条，一方可能要求太多，给对方带来过重的压力';
        }
        ##########################7 5过于冷淡、理性或教条，一方可能要求太多，给对方带来过重的压力 END##########

        ##########################8 6存在金钱物质或价值观方面的冲突 start####################
        if (
            (
                $pls1_2[0]['in_house_id'] == 2
                &&
                (
                    (isset($pls1_2[0]['phase']['0-0'])
                        && in_array($pls1_2[0]['phase']['0-0']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-1'])
                        && in_array($pls1_2[0]['phase']['0-1']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-2'])
                        && in_array($pls1_2[0]['phase']['0-2']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-3'])
                        && in_array($pls1_2[0]['phase']['0-3']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-4'])
                        && in_array($pls1_2[0]['phase']['0-4']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-5'])
                        && in_array($pls1_2[0]['phase']['0-5']['phase_e'], [90, 180]))
                    || (isset($pls1_2[0]['phase']['0-6'])
                        && in_array($pls1_2[0]['phase']['0-6']['phase_e'], [90, 180]))
                )
            )
            ||
            (
                $pls1_2[1]['in_house_id'] == 2
                &&
                (
                    (isset($pls1_2[1]['phase']['1-0'])
                        && in_array($pls1_2[1]['phase']['1-0']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-1'])
                        && in_array($pls1_2[1]['phase']['1-1']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-2'])
                        && in_array($pls1_2[1]['phase']['1-2']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-3'])
                        && in_array($pls1_2[1]['phase']['1-3']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-4'])
                        && in_array($pls1_2[1]['phase']['1-4']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-5'])
                        && in_array($pls1_2[1]['phase']['1-5']['phase_e'], [90, 180]))
                    || (isset($pls1_2[1]['phase']['1-6'])
                        && in_array($pls1_2[1]['phase']['1-6']['phase_e'], [90, 180]))
                )
            )
            ||
            (
                $pls1_2[3]['in_house_id'] == 2
                &&
                (
                    (isset($pls1_2[3]['phase']['3-0'])
                        && in_array($pls1_2[3]['phase']['3-0']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-1'])
                        && in_array($pls1_2[3]['phase']['3-1']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-2'])
                        && in_array($pls1_2[3]['phase']['3-2']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-3'])
                        && in_array($pls1_2[3]['phase']['3-3']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-4'])
                        && in_array($pls1_2[3]['phase']['3-4']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-5'])
                        && in_array($pls1_2[3]['phase']['3-5']['phase_e'], [90, 180]))
                    || (isset($pls1_2[3]['phase']['3-6'])
                        && in_array($pls1_2[3]['phase']['3-6']['phase_e'], [90, 180]))
                )
            )
            ||
            (
                $pls2_2[0]['in_house_id'] == 2
                &&
                (
                    (isset($pls2_2[0]['phase']['0-0'])
                        && in_array($pls2_2[0]['phase']['0-0']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-1'])
                        && in_array($pls2_2[0]['phase']['0-1']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-2'])
                        && in_array($pls2_2[0]['phase']['0-2']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-3'])
                        && in_array($pls2_2[0]['phase']['0-3']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-4'])
                        && in_array($pls2_2[0]['phase']['0-4']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-5'])
                        && in_array($pls2_2[0]['phase']['0-5']['phase_e'], [90, 180]))
                    || (isset($pls2_2[0]['phase']['0-6'])
                        && in_array($pls2_2[0]['phase']['0-6']['phase_e'], [90, 180]))
                )
            )
            ||
            (
                $pls2_2[1]['in_house_id'] == 2
                &&
                (
                    (isset($pls2_2[1]['phase']['1-0'])
                        && in_array($pls2_2[1]['phase']['1-0']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-1'])
                        && in_array($pls2_2[1]['phase']['1-1']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-2'])
                        && in_array($pls2_2[1]['phase']['1-2']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-3'])
                        && in_array($pls2_2[1]['phase']['1-3']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-4'])
                        && in_array($pls2_2[1]['phase']['1-4']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-5'])
                        && in_array($pls2_2[1]['phase']['1-5']['phase_e'], [90, 180]))
                    || (isset($pls2_2[1]['phase']['1-6'])
                        && in_array($pls2_2[1]['phase']['1-6']['phase_e'], [90, 180]))
                )
            )
            ||
            (
                $pls2_2[3]['in_house_id'] == 2
                &&
                (
                    (isset($pls2_2[3]['phase']['3-0'])
                        && in_array($pls2_2[3]['phase']['3-0']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-1'])
                        && in_array($pls2_2[3]['phase']['3-1']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-2'])
                        && in_array($pls2_2[3]['phase']['3-2']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-3'])
                        && in_array($pls2_2[3]['phase']['3-3']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-4'])
                        && in_array($pls2_2[3]['phase']['3-4']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-5'])
                        && in_array($pls2_2[3]['phase']['3-5']['phase_e'], [90, 180]))
                    || (isset($pls2_2[3]['phase']['3-6'])
                        && in_array($pls2_2[3]['phase']['3-6']['phase_e'], [90, 180]))
                )
            )
        )
        {
            $phase_180_house28 = false;
            $phase_90180_house28 = false;
            for ($i = 0; $i < 7; $i++)
            {
                if (!empty($pls1[$i]['or_phase']))
                {
                    foreach ($pls1[$i]['or_phase'] as $ps)
                    {
                        if (
                            $i < 5
                            &&
                            $ps['phase_e'] == 180
                            &&
                            (
                                in_array($pls1[$i]['in_house_id'], [2, 8])
                                || in_array($pls1[$ps['id']]['in_house_id'], [2, 8])
                            )
                        )
                        {
                            $phase_180_house28 = true;
                        }
                        if (
                            in_array($ps['phase_e'], [90, 180])
                            &&
                            !in_array($ps['id'], [7, 8, 9])
                            &&
                            (
                                in_array($pls1[$i]['in_house_id'], [2, 8])
                                || in_array($pls1[$ps['id']]['in_house_id'], [2, 8])
                            )
                        )
                        {
                            $phase_90180_house28 = true;
                        }
                    }
                }
                if (!empty($pls1_2[$i]['or_phase']))
                {
                    foreach ($pls1_2[$i]['or_phase'] as $ps)
                    {
                        if (
                            $i < 5
                            &&
                            $ps['phase_e'] == 180
                            &&
                            (
                                in_array($pls2[$i]['in_house_id'], [2, 8])
                                || in_array($pls2[$ps['id']]['in_house_id'], [2, 8])
                            )
                        )
                        {
                            $phase_180_house28 = true;
                        }
                        if (
                            in_array($ps['phase_e'], [90, 180])
                            &&
                            !in_array($ps['id'], [7, 8, 9])
                            &&
                            (
                                in_array($pls2[$i]['in_house_id'], [2, 8])
                                || in_array($pls2[$ps['id']]['in_house_id'], [2, 8])
                            )
                        )
                        {
                            $phase_90180_house28 = true;
                        }
                    }
                }
            }
            if (
                (
                    isset($pls1[3]['or_phase']['3-1'])
                    && in_array($pls1[3]['or_phase']['3-1']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-4'])
                    && in_array($pls1[3]['or_phase']['3-4']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-6'])
                    && in_array($pls1[3]['or_phase']['3-6']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-8'])
                    && in_array($pls1[3]['or_phase']['3-8']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-1'])
                    && in_array($pls1[3]['or_phase']['3-1']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-4'])
                    && in_array($pls1[3]['or_phase']['3-4']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-6'])
                    && in_array($pls1[3]['or_phase']['3-6']['phase_e'], [90, 180])
                )
                ||
                (
                    isset($pls1[3]['or_phase']['3-8'])
                    && in_array($pls1[3]['or_phase']['3-8']['phase_e'], [90, 180])
                )
                ||
                $phase_180_house28
                ||
                $phase_90180_house28
            )
            {
                $ret2[] = '存在金钱物质或价值观方面的冲突';
            }
        }
        ##########################8 6存在金钱物质或价值观方面的冲突 END####################

        ##########################9 7彼此性格差异过大 start####################
        if (
            (
                (
                    (
                        $pls1_2[0]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[0]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[0]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && (!isset($pls1_2[0]['phase']['0-0'])
                            || !in_array($pls1_2[0]['phase']['0-0']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[0]['phase']['0-1'])
                            || !in_array($pls1_2[0]['phase']['0-1']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[0]['phase']['0-' . ASC])
                            || !in_array($pls1_2[0]['phase']['0-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls1_2[0]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[0]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[0]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && $pls1_2[0]['in_sign_id'] % 4 != $pls1[0]['in_sign_id'] % 4
                        && $pls1_2[0]['in_sign_id'] % 4 != $pls1[1]['in_sign_id'] % 4
                        && $pls1_2[0]['in_sign_id'] % 4 != $pls1[ASC]['in_sign_id'] % 4
                    )
                )
                &&
                (
                    (
                        $pls1_2[1]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[1]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[1]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && (!isset($pls1_2[1]['phase']['1-0'])
                            || !in_array($pls1_2[1]['phase']['1-0']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[1]['phase']['1-1'])
                            || !in_array($pls1_2[1]['phase']['1-1']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[1]['phase']['1-' . ASC])
                            || !in_array($pls1_2[1]['phase']['1-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls1_2[1]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[1]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[1]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && $pls1_2[1]['in_sign_id'] % 4 != $pls1[0]['in_sign_id'] % 4
                        && $pls1_2[1]['in_sign_id'] % 4 != $pls1[1]['in_sign_id'] % 4
                        && $pls1_2[1]['in_sign_id'] % 4 != $pls1[ASC]['in_sign_id'] % 4
                    )
                )
                &&
                (
                    (
                        $pls1_2[ASC]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[ASC]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[ASC]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && (!isset($pls1_2[ASC]['phase'][ASC . '-0'])
                            || !in_array($pls1_2[ASC]['phase'][ASC . '-0']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[ASC]['phase'][ASC . '-1'])
                            || !in_array($pls1_2[ASC]['phase'][ASC . '-1']['phase_e'], [60, 120]))
                        && (!isset($pls1_2[ASC]['phase'][ASC . '-' . ASC])
                            || !in_array($pls1_2[ASC]['phase'][ASC . '-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls1_2[ASC]['in_sign_id'] != $pls1[0]['in_sign_id']
                        && $pls1_2[ASC]['in_sign_id'] != $pls1[1]['in_sign_id']
                        && $pls1_2[ASC]['in_sign_id'] != $pls1[ASC]['in_sign_id']
                        && $pls1_2[ASC]['in_sign_id'] % 4 != $pls1[0]['in_sign_id'] % 4
                        && $pls1_2[ASC]['in_sign_id'] % 4 != $pls1[1]['in_sign_id'] % 4
                        && $pls1_2[ASC]['in_sign_id'] % 4 != $pls1[ASC]['in_sign_id'] % 4
                    )
                )
            )
            ||
            (
                (
                    (
                        $pls2_2[0]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[0]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[0]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && (!isset($pls2_2[0]['phase']['0-0'])
                            || !in_array($pls2_2[0]['phase']['0-0']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[0]['phase']['0-1'])
                            || !in_array($pls2_2[0]['phase']['0-1']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[0]['phase']['0-' . ASC])
                            || !in_array($pls2_2[0]['phase']['0-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls2_2[0]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[0]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[0]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && $pls2_2[0]['in_sign_id'] % 4 != $pls2[0]['in_sign_id'] % 4
                        && $pls2_2[0]['in_sign_id'] % 4 != $pls2[1]['in_sign_id'] % 4
                        && $pls2_2[0]['in_sign_id'] % 4 != $pls2[ASC]['in_sign_id'] % 4
                    )
                )
                &&
                (
                    (
                        $pls2_2[1]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[1]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[1]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && (!isset($pls2_2[1]['phase']['1-0'])
                            || !in_array($pls2_2[1]['phase']['1-0']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[1]['phase']['1-1'])
                            || !in_array($pls2_2[1]['phase']['1-1']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[1]['phase']['1-' . ASC])
                            || !in_array($pls2_2[1]['phase']['1-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls2_2[1]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[1]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[1]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && $pls2_2[1]['in_sign_id'] % 4 != $pls2[0]['in_sign_id'] % 4
                        && $pls2_2[1]['in_sign_id'] % 4 != $pls2[1]['in_sign_id'] % 4
                        && $pls2_2[1]['in_sign_id'] % 4 != $pls2[ASC]['in_sign_id'] % 4
                    )
                )
                &&
                (
                    (
                        $pls2_2[ASC]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[ASC]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[ASC]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && (!isset($pls2_2[ASC]['phase'][ASC . '-0'])
                            || !in_array($pls2_2[ASC]['phase'][ASC . '-0']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[ASC]['phase'][ASC . '-1'])
                            || !in_array($pls2_2[ASC]['phase'][ASC . '-1']['phase_e'], [60, 120]))
                        && (!isset($pls2_2[ASC]['phase'][ASC . '-' . ASC])
                            || !in_array($pls2_2[ASC]['phase'][ASC . '-' . ASC]['phase_e'], [60, 120]))
                    )
                    ||
                    (
                        $pls2_2[ASC]['in_sign_id'] != $pls2[0]['in_sign_id']
                        && $pls2_2[ASC]['in_sign_id'] != $pls2[1]['in_sign_id']
                        && $pls2_2[ASC]['in_sign_id'] != $pls2[ASC]['in_sign_id']
                        && $pls2_2[ASC]['in_sign_id'] % 4 != $pls2[0]['in_sign_id'] % 4
                        && $pls2_2[ASC]['in_sign_id'] % 4 != $pls2[1]['in_sign_id'] % 4
                        && $pls2_2[ASC]['in_sign_id'] % 4 != $pls2[ASC]['in_sign_id'] % 4
                    )
                )
            )
        )
        {
            $ret2[] = '彼此性格差异较大';
        }
        ##########################9 7彼此性格差异过大 END####################

        ##########################10 8缺乏真正共同的兴趣和爱好，彼此较少好感的基础，相处难以顺畅舒适 start###########
        if (
            $pls1[0]['in_sign_id'] != $pls2[0]['in_sign_id']
            &&
            $pls1[3]['in_sign_id'] != $pls2[3]['in_sign_id']
            && (!isset($pls1[3]['phase']['3-' . ASC]) || !in_array($pls1[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
            && (!isset($pls1[3]['phase']['3-' . MC]) || !in_array($pls1[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
            && (!isset($pls2[3]['phase']['3-' . ASC]) || !in_array($pls2[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
            && (!isset($pls2[3]['phase']['3-' . MC]) || !in_array($pls2[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
            && (!isset($pls1[0]['phase']['0-1']) || !in_array($pls1[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            && (!isset($pls1[1]['phase']['1-1']) || !in_array($pls1[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
            && (!isset($pls1[1]['phase']['1-0']) || !in_array($pls1[1]['phase']['1-0']['phase_e'], [0, 60, 120]))
        )
        {
            $has_phase = 0;
            $has_phase_deg = [];
            if (!empty($pls1[3]['phase']))
            {
                foreach ($pls1[3]['phase'] as $ps)
                {
                    if ($ps['id'] < 5)
                    {
                        $has_phase++;
                        if (!in_array($ps['phase_e'], $has_phase_deg))
                        {
                            $has_phase_deg[] = $ps['phase_e'];
                        }
                    }
                }
            }
            if (!empty($pls2[3]['phase']))
            {
                foreach ($pls2[3]['phase'] as $ps)
                {
                    if ($ps['id'] < 5)
                    {
                        $has_phase++;
                        if (!in_array($ps['phase_e'], $has_phase_deg))
                        {
                            $has_phase_deg[] = $ps['phase_e'];
                        }
                    }
                }
            }
            if ($has_phase == 0 || (count($has_phase_deg) == 1 && $has_phase_deg[0] == 90))
            {
                $ret2[] = '缺乏真正共同的兴趣和爱好，彼此较少好感的基础，相处难以顺畅舒适';
            }
        }
        ##########################10 8缺乏真正共同的兴趣和爱好，彼此较少好感的基础，相处难以顺畅舒适 END#############

        ##########################11 9随着彼此的进一步熟悉，新奇感减弱，冲突会越发明显和强烈，需要努力协调 start#######
        if ($foothold_11 >= 2)
        {
            $ret2[] = '随着彼此的进一步熟悉，新奇感减弱，冲突会越发明显和强烈，需要努力协调';
        }
        ##########################11 9随着彼此的进一步熟悉，新奇感减弱，冲突会越发明显和强烈，需要努力协调 END#######

        ##########################12 人生态度和世界观、价值观有较多不同，甚至相互抵触 start####################
        $c10 = false;
        if (
            $pls1[0]['in_sign_id'] != 10
            && $pls1[1]['in_sign_id'] != 10
            && $pls1[2]['in_sign_id'] != 10
            && $pls1[3]['in_sign_id'] != 10
            && $pls1[4]['in_sign_id'] != 10
            && !in_array($pls2[0]['in_sign_id'], [5, 9, 12])
            && !in_array($pls2[1]['in_sign_id'], [5, 9, 12])
            && !in_array($pls2[2]['in_sign_id'], [5, 9, 12])
            && !in_array($pls2[3]['in_sign_id'], [5, 9, 12])
            && !in_array($pls2[4]['in_sign_id'], [5, 9, 12])
        )
        {
            if (
                (
                    !isset($pls1[0]['phase']['0-6'])
                    || !in_array($pls1[0]['phase']['0-6']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls1[1]['phase']['1-6'])
                    || !in_array($pls1[1]['phase']['1-6']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls1[6]['phase']['6-' . ASC])
                    || !in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180])
                )
                &&
                (
                    !isset($pls1[6]['phase']['6-' . MC])
                    || !in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180])
                )
                &&
                (
                    (
                        isset($pls1[0]['phase']['0-5'])
                        && in_array($pls1[0]['phase']['0-5']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-5'])
                        && in_array($pls1[1]['phase']['1-5']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-5'])
                        && in_array($pls1[3]['phase']['3-5']['phase_e'], [90, 180])
                    )
                )
                &&
                (
                    isset($pls2[0]['phase']['0-5'])
                    && in_array($pls2[0]['phase']['0-5']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    isset($pls2[1]['phase']['1-5'])
                    && in_array($pls2[1]['phase']['1-5']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls2[5]['phase']['5-' . ASC])
                    || !in_array($pls2[5]['phase']['5-' . ASC]['phase_e'], [0, 180])
                )
                &&
                (
                    !isset($pls2[5]['phase']['5-' . MC])
                    || !in_array($pls2[5]['phase']['5-' . MC]['phase_e'], [0, 180])
                )
                &&
                (
                    (
                        isset($pls2[0]['phase']['0-6'])
                        && in_array($pls2[0]['phase']['0-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-6'])
                        && in_array($pls2[1]['phase']['1-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-6'])
                        && in_array($pls2[3]['phase']['3-6']['phase_e'], [90, 180])
                    )
                )
            )
            {
                $c10 = true;
            }
        }
        if (
            $pls2[0]['in_sign_id'] != 10
            && $pls2[1]['in_sign_id'] != 10
            && $pls2[2]['in_sign_id'] != 10
            && $pls2[3]['in_sign_id'] != 10
            && $pls2[4]['in_sign_id'] != 10
            && !in_array($pls1[0]['in_sign_id'], [5, 9, 12])
            && !in_array($pls1[1]['in_sign_id'], [5, 9, 12])
            && !in_array($pls1[2]['in_sign_id'], [5, 9, 12])
            && !in_array($pls1[3]['in_sign_id'], [5, 9, 12])
            && !in_array($pls1[4]['in_sign_id'], [5, 9, 12])
        )
        {
            if (
                (
                    !isset($pls2[0]['phase']['0-6'])
                    || !in_array($pls2[0]['phase']['0-6']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls2[1]['phase']['1-6'])
                    || !in_array($pls2[1]['phase']['1-6']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls2[6]['phase']['6-' . ASC])
                    || !in_array($pls2[6]['phase']['6-' . ASC]['phase_e'], [0, 180])
                )
                &&
                (
                    !isset($pls2[6]['phase']['6-' . MC])
                    || !in_array($pls2[6]['phase']['6-' . MC]['phase_e'], [0, 180])
                )
                &&
                (
                    (
                        isset($pls2[0]['phase']['0-5'])
                        && in_array($pls2[0]['phase']['0-5']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-5'])
                        && in_array($pls2[1]['phase']['1-5']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-5'])
                        && in_array($pls2[3]['phase']['3-5']['phase_e'], [90, 180])
                    )
                )
                &&
                (
                    isset($pls1[0]['phase']['0-5'])
                    && in_array($pls1[0]['phase']['0-5']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    isset($pls1[1]['phase']['1-5'])
                    && in_array($pls1[1]['phase']['1-5']['phase_e'], [0, 90, 180])
                )
                &&
                (
                    !isset($pls1[5]['phase']['5-' . ASC])
                    || !in_array($pls1[5]['phase']['5-' . ASC]['phase_e'], [0, 180])
                )
                &&
                (
                    !isset($pls1[5]['phase']['5-' . MC])
                    || !in_array($pls1[5]['phase']['5-' . MC]['phase_e'], [0, 180])
                )
                &&
                (
                    (
                        isset($pls1[0]['phase']['0-6'])
                        && in_array($pls1[0]['phase']['0-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-6'])
                        && in_array($pls1[1]['phase']['1-6']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-6'])
                        && in_array($pls1[3]['phase']['3-6']['phase_e'], [90, 180])
                    )
                )
            )
            {
                $c10 = true;
            }
        }
        if ($c10 === true)
        {
            $ret2[] = '人生态度和世界观、价值观有较多不同，甚至相互抵触';
        }
        ##########################12 人生态度和世界观、价值观有较多不同，甚至相互抵触 END####################

        ###########################添加1：双方的个人喜好、审美观、价值观存在分歧，容易引发争执 start#########################
        // 双方金星都与对方太阳或月亮或金星产生刑相位
        if (
            (
                (isset($pls1[3]['phase']['3-0']) && $pls1[3]['phase']['3-0']['phase_e'] == 90)
                ||
                (isset($pls1[3]['phase']['3-1']) && $pls1[3]['phase']['3-1']['phase_e'] == 90)
                ||
                (isset($pls1[3]['phase']['3-3']) && $pls1[3]['phase']['3-3']['phase_e'] == 90)
            )
            &&
            (
                (isset($pls2[3]['phase']['3-0']) && $pls2[3]['phase']['3-0']['phase_e'] == 90)
                ||
                (isset($pls2[3]['phase']['3-1']) && $pls2[3]['phase']['3-1']['phase_e'] == 90)
            )
        )
        {
            $ret2[] = '双方的个人喜好、审美观、价值观存在分歧，容易引发争执';
        }
        ###########################添加1：双方的个人喜好、审美观、价值观存在分歧，容易引发争执  END#########################

        ###########################添加2：容易各持己见，互不妥协 start#########################
        if (
        (
            (
                (
                    (isset($pls1[0]['or_phase']['0-7']) && in_array($pls1[0]['or_phase']['0-7']['phase_e'], [0, 90, 180]))
                    ||
                    (isset($pls1[1]['or_phase']['1-7']) && in_array($pls1[1]['or_phase']['1-7']['phase_e'], [0, 90, 180]))
                    ||
                    (isset($pls1[7]['or_phase']['7-' . ASC]) && in_array($pls1[7]['or_phase']['7-' . ASC]['phase_e'], [0, 180]))
                    ||
                    (isset($pls1[7]['or_phase']['7-' . MC]) && in_array($pls1[7]['or_phase']['7-' . MC]['phase_e'], [0, 180]))
                    ||
                    $pls1[0]['in_sign_id'] == 11
                    ||
                    $pls1[1]['in_sign_id'] == 11
                )
                &&
                (
                    isset($pls1[0]['or_phase']['0-4'])
                    ||
                    isset($pls1[1]['or_phase']['1-4'])
                    ||
                    $pls1[0]['in_sign_id'] == 1
                    ||
                    $pls1[1]['in_sign_id'] == 1
                    ||
                    (isset($pls1[4]['or_phase']['4-' . ASC]) && in_array($pls1[4]['or_phase']['4-' . ASC]['phase_e'], [0, 180]))
                    ||
                    (isset($pls1[4]['or_phase']['4-' . MC]) && in_array($pls1[4]['or_phase']['4-' . MC]['phase_e'], [0, 180]))
                )
                &&
                (
                    $pls2[0]['in_sign_id'] == 5 || $pls2[1]['in_sign_id'] == 5
                )
            )
            ||
            (
                (
                    (isset($pls2[0]['or_phase']['0-7']) && in_array($pls2[0]['or_phase']['0-7']['phase_e'], [0, 90, 180]))
                    ||
                    (isset($pls2[1]['or_phase']['1-7']) && in_array($pls2[1]['or_phase']['1-7']['phase_e'], [0, 90, 180]))
                    ||
                    (isset($pls2[7]['or_phase']['7-' . ASC]) && in_array($pls2[7]['or_phase']['7-' . ASC]['phase_e'], [0, 180]))
                    ||
                    (isset($pls2[7]['or_phase']['7-' . MC]) && in_array($pls2[7]['or_phase']['7-' . MC]['phase_e'], [0, 180]))
                    ||
                    $pls2[0]['in_sign_id'] == 11
                    ||
                    $pls2[1]['in_sign_id'] == 11
                )
                &&
                (
                    isset($pls2[0]['or_phase']['0-4'])
                    ||
                    isset($pls2[1]['or_phase']['1-4'])
                    ||
                    $pls2[0]['in_sign_id'] == 1
                    ||
                    $pls2[1]['in_sign_id'] == 1
                    ||
                    (isset($pls2[4]['or_phase']['4-' . ASC]) && in_array($pls2[4]['or_phase']['4-' . ASC]['phase_e'], [0, 180]))
                    ||
                    (isset($pls2[4]['or_phase']['4-' . MC]) && in_array($pls2[4]['or_phase']['4-' . MC]['phase_e'], [0, 180]))
                )
                &&
                (
                    $pls1[0]['in_sign_id'] == 5 || $pls1[1]['in_sign_id'] == 5
                )
            )
        )
        )
        {
            $ret2[] = '容易各持己见，互不妥协';
        }
        ###########################添加2：容易各持己见，互不妥协  END#########################

        #########1.29添加3：行动目标不一致，并容易给对方带来限制或冲突的感觉，需要平心静气相互协调，尽可能求同存异  start#########
        // 存在火星刑火星或火星刑土星
        if (
            (isset($pls1[4]['phase']['4-4']) && $pls1[4]['phase']['4-4']['phase_e'] == 90)
            || (isset($pls1[4]['phase']['4-6']) && $pls1[4]['phase']['4-6']['phase_e'] == 90)
            || (isset($pls1[6]['phase']['6-4']) && $pls1[6]['phase']['6-4']['phase_e'] == 90)
        )
        {
            $ret2[] = '行动目标不一致，并容易给对方带来限制或冲突的感觉，需要平心静气相互协调，尽可能求同存异';
        }
        #########1.29添加3：行动目标不一致，并容易给对方带来限制或冲突的感觉，需要平心静气相互协调，尽可能求同存异  end#########


        #########1.29添加4：一方对另一方的管束或经验传授有抵触心理，很容易觉得被冒犯或承受太多压力  start#########
        // 若双方存在月土刑冲合，且有月火刑冲合或日火刑冲合，而月亮方是月白羊或火白羊或 有日火相位或有火天相位或有日天刑冲或有月天刑冲
        if (
            (
                (isset($pls1[1]['phase']['1-4']) && in_array($pls1[1]['phase']['1-4']['phase_e'], [0, 90, 180]))
                || (isset($pls2[1]['phase']['1-4']) && in_array($pls2[1]['phase']['1-4']['phase_e'], [0, 90, 180]))
                || (isset($pls1[0]['phase']['0-4']) && in_array($pls1[0]['phase']['0-4']['phase_e'], [0, 90, 180]))
                || (isset($pls2[0]['phase']['0-4']) && in_array($pls2[0]['phase']['0-4']['phase_e'], [0, 90, 180]))
            )
            &&
            (
                (
                    (isset($pls1[1]['phase']['1-6']) && in_array($pls1[1]['phase']['1-6']['phase_e'], [0, 90, 180]))
                    &&
                    (
                        $pls1[1]['in_sign_id'] == 1
                        || $pls1[4]['in_sign_id'] == 1
                        || isset($pls1[0]['or_phase']['0-4'])
                        || isset($pls1[4]['or_phase']['4-7'])
                        || (isset($pls1[0]['or_phase']['0-7']) && in_array($pls1[0]['or_phase']['0-7']['phase_e'], [90, 180]))
                        || (isset($pls1[1]['or_phase']['1-7']) && in_array($pls1[1]['or_phase']['1-7']['phase_e'], [90, 180]))
                    )
                )
                ||
                (
                    (isset($pls2[1]['phase']['1-6']) && in_array($pls2[1]['phase']['1-6']['phase_e'], [0, 90, 180]))
                    &&
                    (
                        $pls2[1]['in_sign_id'] == 1
                        || $pls2[4]['in_sign_id'] == 1
                        || isset($pls2[0]['or_phase']['0-4'])
                        || isset($pls2[4]['or_phase']['4-7'])
                        || (isset($pls2[0]['or_phase']['0-7']) && in_array($pls2[0]['or_phase']['0-7']['phase_e'], [90, 180]))
                        || (isset($pls2[1]['or_phase']['1-7']) && in_array($pls2[1]['or_phase']['1-7']['phase_e'], [90, 180]))
                    )
                )
            )
        )
        {
            $ret2[] = '一方对另一方的管束或经验传授有抵触心理，很容易觉得被冒犯或承受太多压力';
        }
        #########1.29添加4：一方对另一方的管束或经验传授有抵触心理，很容易觉得被冒犯或承受太多压力  end#########


        #########1.29添加5：有时会觉得交流比较吃力，或对对方的表达方式不太认同甚至反感，进而引发争吵或冷漠以对。  start#########
        // 若双方水星均被对方火刑冲或土刑冲
        if (
            (
                (isset($pls1[2]['phase']['2-4']) && in_array($pls1[2]['phase']['2-4']['phase_e'], [90, 180]))
                || (isset($pls1[2]['phase']['2-6']) && in_array($pls1[2]['phase']['2-6']['phase_e'], [90, 180]))
            )
            &&
            (
                (isset($pls2[2]['phase']['2-4']) && in_array($pls2[2]['phase']['2-4']['phase_e'], [90, 180]))
                || (isset($pls2[2]['phase']['2-6']) && in_array($pls2[2]['phase']['2-6']['phase_e'], [90, 180]))
            )
        )
        {
            $ret2[] = '有时会觉得交流比较吃力，或对对方的表达方式不太认同甚至反感，进而引发争吵或冷漠以对';
        }
        #########1.29添加5：有时会觉得交流比较吃力，或对对方的表达方式不太认同甚至反感，进而引发争吵或冷漠以对。  end#########

        ########################2.6 若付出感情或深入交往，一方或双方容易受到伤害 start###########################
        // 	一方月亮与另一方火土同时成相，且该月亮至少与对方日月火土冥之一形成刑冲（其中冥王相位在1度以内）
        if (
            (
                (isset($pls1[1]['phase']['1-4']) || isset($pls1[1]['phase']['1-6']))
                &&
                (
                    (isset($pls1[1]['phase']['1-0']) && in_array($pls1[1]['phase']['1-0'], [90, 180]))
                    || (isset($pls1[1]['phase']['1-1']) && in_array($pls1[1]['phase']['1-1'], [90, 180]))
                    || (isset($pls1[1]['phase']['1-4']) && in_array($pls1[1]['phase']['1-4'], [90, 180]))
                    || (isset($pls1[1]['phase']['1-6']) && in_array($pls1[1]['phase']['1-6'], [90, 180]))
                    || (isset($pls1[1]['phase']['1-9'])
                        && $pls1[1]['phase']['1-9']['phase_orb'] < 1
                        && in_array($pls1[1]['phase']['1-9'], [90, 180])
                    )
                )
            )
            ||
            (
                (isset($pls2[1]['phase']['1-4']) || isset($pls2[1]['phase']['1-6']))
                &&
                (
                    (isset($pls2[1]['phase']['1-0']) && in_array($pls2[1]['phase']['1-0'], [90, 180]))
                    || (isset($pls2[1]['phase']['1-1']) && in_array($pls2[1]['phase']['1-1'], [90, 180]))
                    || (isset($pls2[1]['phase']['1-4']) && in_array($pls2[1]['phase']['1-4'], [90, 180]))
                    || (isset($pls2[1]['phase']['1-6']) && in_array($pls2[1]['phase']['1-6'], [90, 180]))
                    || (isset($pls2[1]['phase']['1-9'])
                        && $pls2[1]['phase']['1-9']['phase_orb'] < 1
                        && in_array($pls2[1]['phase']['1-9'], [90, 180])
                    )
                )
            )
        )
        {
            $ret2[] = '若付出感情或深入交往，一方或双方容易受到伤害';
        }
        ########################2.6 若付出感情或深入交往，一方或双方容易受到伤害 end###########################


        ##########################13 女神暂时没找到你们相处的问题，那你们很可能相处得非常融洽，请好好珍惜彼此！ start######
        if (empty($ret2))
        {
            $ret2[] = '女神暂时没找到你们相处的问题，那你们很可能相处得非常融洽，请好好珍惜彼此';
        }
        ##########################13 女神暂时没找到你们相处的问题，那你们很可能相处得非常融洽，请好好珍惜彼此！ END#######


        #---------------------------------------------------------------------------------#
        #---------------------------------------------------------------------------------#
        #------------------------------------双方得失---------------------------------------#
        #---------------------------------------------------------------------------------#
        #---------------------------------------------------------------------------------#
        // 成长  物质 关爱 激励 安全 幸运
        $score1 = ['grow' => 0, 'substance' => 0, 'care' => 0, 'motivate' => 0, 'relieved' => 0, 'luck' => 0];// B in A
        $score2 = ['grow' => 0, 'substance' => 0, 'care' => 0, 'motivate' => 0, 'relieved' => 0, 'luck' => 0];// A in B
        // 成长
        // 成长（若不满足“谈天说地轻松愉悦”一项且不满足“相互信赖”一项，分数折半，若两项都满足分组*1.5）
        // 彼土合我日月+20（拱六分+10，冲+5），
        // 若此时彼木合我轴或彼木与我日月成相+10，若此时彼水合拱六分我月或彼月合拱六分我水或我水合拱六分彼水或我水合拱六分彼木+10
        // 彼日合拱六分我月+10（冲+8），若此时，彼日落我3/6/9/10/11宫+8
        // 彼日合我中天+8
        // 彼木合我日月+10（拱六分+7，冲+3），若此时彼木落我3/6/9/10宫+6
        // 彼木落我7宫+10，落我1宫+5
        // 彼土落我7宫+8，落我1宫+4
        $sg = 0;
        if (isset($pls1_2[6]['phase']['6-0']) || isset($pls1_2[6]['phase']['6-1']))
        {
            if (
                (
                    isset($pls1_2[6]['phase']['6-0'])
                    && $pls1_2[6]['phase']['6-0']['phase_e'] == 0
                )
                ||
                (
                    isset($pls1_2[6]['phase']['6-1'])
                    && $pls1_2[6]['phase']['6-1']['phase_e'] == 0
                )
            )
            {
                $sg += 20;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls1_2[5]['phase']['5-' . ASC]) && in_array($pls1_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls1_2[5]['phase']['5-' . MC]) && in_array($pls1_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls1_2[5]['phase']['5-0'])
                    || isset($pls1_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls1_2[2]['phase']['2-1']) && in_array($pls1_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1_2[1]['phase']['1-2']) && in_array($pls1_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-2']) && in_array($pls1[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-5']) && in_array($pls1[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            } elseif (
                (
                    isset($pls1_2[6]['phase']['6-0'])
                    && $pls1_2[6]['phase']['6-0']['phase_e'] == 120
                )
                ||
                (
                    isset($pls1_2[6]['phase']['6-1'])
                    && $pls1_2[6]['phase']['6-1']['phase_e'] == 120
                )
            )
            {
                $sg += 10;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls1_2[5]['phase']['5-' . ASC]) && in_array($pls1_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls1_2[5]['phase']['5-' . MC]) && in_array($pls1_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls1_2[5]['phase']['5-0'])
                    || isset($pls1_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls1_2[2]['phase']['2-1']) && in_array($pls1_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1_2[1]['phase']['1-2']) && in_array($pls1_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-2']) && in_array($pls1[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-5']) && in_array($pls1[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            } elseif (
                (
                    isset($pls1_2[6]['phase']['6-0'])
                    && $pls1_2[6]['phase']['6-0']['phase_e'] == 180
                )
                ||
                (
                    isset($pls1_2[6]['phase']['6-1'])
                    && $pls1_2[6]['phase']['6-1']['phase_e'] == 180
                )
            )
            {
                $sg += 5;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls1_2[5]['phase']['5-' . ASC]) && in_array($pls1_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls1_2[5]['phase']['5-' . MC]) && in_array($pls1_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls1_2[5]['phase']['5-0'])
                    || isset($pls1_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls1_2[2]['phase']['2-1']) && in_array($pls1_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1_2[1]['phase']['1-2']) && in_array($pls1_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-2']) && in_array($pls1[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-5']) && in_array($pls1[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            }
        }
        if (isset($pls1_2[0]['phase']['0-1']))
        {
            if (in_array($pls1_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sg += 10;
                // 若此时，彼日落我3/6/9/10/11宫+8
                if (in_array($pls1_2[0]['in_house_id'], [3, 6, 9, 10, 11]))
                {
                    $sg += 8;
                }
            } elseif ($pls1_2[0]['phase']['0-1']['phase_e'] == 180)
            {
                $sg += 8;
                // 若此时，彼日落我3/6/9/10/11宫+8
                if (in_array($pls1_2[0]['in_house_id'], [3, 6, 9, 10, 11]))
                {
                    $sg += 8;
                }
            }
        }
        if (isset($pls1_2[0]['phase']['0-' . MC]) && $pls1_2[0]['phase']['0-' . MC]['phase_e'] == 0)
        {
            $sg += 8;
        }
        if (isset($pls1_2[5]['phase']['5-0']) || isset($pls1_2[6]['phase']['5-1']))
        {
            if (
                (
                    isset($pls1_2[5]['phase']['5-0'])
                    && $pls1_2[5]['phase']['5-0']['phase_e'] == 0
                )
                ||
                (
                    isset($pls1_2[5]['phase']['5-1'])
                    && $pls1_2[5]['phase']['5-1']['phase_e'] == 0
                )
            )
            {
                $sg += 10;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls1_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }

            } elseif (
                (
                    isset($pls1_2[5]['phase']['5-0'])
                    && ($pls1_2[5]['phase']['5-0']['phase_e'] == 60
                        || $pls1_2[5]['phase']['5-0']['phase_e'] == 120)
                )
                ||
                (
                    isset($pls1_2[5]['phase']['5-1'])
                    && ($pls1_2[5]['phase']['5-1']['phase_e'] == 60
                        || $pls1_2[5]['phase']['5-1']['phase_e'] == 120)
                )
            )
            {
                $sg += 7;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls1_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }
            } elseif (
                (
                    isset($pls1_2[5]['phase']['5-0'])
                    && $pls1_2[5]['phase']['5-0']['phase_e'] == 180
                )
                ||
                (
                    isset($pls1_2[5]['phase']['5-1'])
                    && $pls1_2[5]['phase']['5-1']['phase_e'] == 180
                )
            )
            {
                $sg += 3;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls1_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }
            }
        }
        if ($pls1_2[5]['in_house_id'] == 7)
        {
            $sg += 10;
        } elseif ($pls1_2[5]['in_house_id'] == 1)
        {
            $sg += 5;
        }
        if ($pls1_2[6]['in_house_id'] == 7)
        {
            $sg += 8;
        } elseif ($pls1_2[6]['in_house_id'] == 1)
        {
            $sg += 4;
        }
        if (
            ($foothold_2 >= 5 && $foothold_2_bad >= -2)
            &&
            (
                ($foothold_3_bad == 0 && $foothold_3 > 2)
                || ($foothold_3_bad >= -2 && $foothold_3 > 3.5)
            )
        )
        {
            $sg *= 1.5;
        } elseif (
            ($foothold_2 < 5 || $foothold_2_bad < -2)
            &&
            (
                ($foothold_3_bad != 0 || $foothold_3 <= 2)
                || ($foothold_3_bad < -2 || $foothold_3 <= 3.5)
            )
        )
        {
            $sg *= 0.5;
        }
        $score1['grow'] += $sg;

        $sg = 0;
        if (isset($pls2_2[6]['phase']['6-0']) || isset($pls2_2[6]['phase']['6-1']))
        {
            if (
                (
                    isset($pls2_2[6]['phase']['6-0'])
                    && $pls2_2[6]['phase']['6-0']['phase_e'] == 0
                )
                ||
                (
                    isset($pls2_2[6]['phase']['6-1'])
                    && $pls2_2[6]['phase']['6-1']['phase_e'] == 0
                )
            )
            {
                $sg += 20;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls2_2[5]['phase']['5-' . ASC]) && in_array($pls2_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls2_2[5]['phase']['5-' . MC]) && in_array($pls2_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls2_2[5]['phase']['5-0'])
                    || isset($pls2_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls2_2[2]['phase']['2-1']) && in_array($pls2_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2_2[1]['phase']['1-2']) && in_array($pls2_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-2']) && in_array($pls2[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-5']) && in_array($pls2[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            } elseif (
                (
                    isset($pls2_2[6]['phase']['6-0'])
                    && $pls2_2[6]['phase']['6-0']['phase_e'] == 120
                )
                ||
                (
                    isset($pls2_2[6]['phase']['6-1'])
                    && $pls2_2[6]['phase']['6-1']['phase_e'] == 120
                )
            )
            {
                $sg += 10;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls2_2[5]['phase']['5-' . ASC]) && in_array($pls2_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls2_2[5]['phase']['5-' . MC]) && in_array($pls2_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls2_2[5]['phase']['5-0'])
                    || isset($pls2_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls2_2[2]['phase']['2-1']) && in_array($pls2_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2_2[1]['phase']['1-2']) && in_array($pls2_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-2']) && in_array($pls2[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-5']) && in_array($pls2[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            } elseif (
                (
                    isset($pls2_2[6]['phase']['6-0'])
                    && $pls2_2[6]['phase']['6-0']['phase_e'] == 180
                )
                ||
                (
                    isset($pls2_2[6]['phase']['6-1'])
                    && $pls2_2[6]['phase']['6-1']['phase_e'] == 180
                )
            )
            {
                $sg += 5;
                // 若此时彼木合我轴或彼木与我日月成相+10，
                if (
                    (
                        isset($pls2_2[5]['phase']['5-' . ASC]) && in_array($pls2_2[5]['phase']['5-' . ASC], [0, 180])
                    )
                    ||
                    (
                        isset($pls2_2[5]['phase']['5-' . MC]) && in_array($pls2_2[5]['phase']['5-' . MC], [0, 180])
                    )
                    || isset($pls2_2[5]['phase']['5-0'])
                    || isset($pls2_2[5]['phase']['5-1'])
                )
                {
                    $sg += 10;
                }
                // 若此时彼水合拱六分我月 或彼月合拱六分我水 或我水合拱六分彼水 或我水合拱六分彼木+10
                if (
                    (
                        isset($pls2_2[2]['phase']['2-1']) && in_array($pls2_2[2]['phase']['2-1'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2_2[1]['phase']['1-2']) && in_array($pls2_2[1]['phase']['1-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-2']) && in_array($pls2[2]['phase']['2-2'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-5']) && in_array($pls2[2]['phase']['2-5'], [0, 60, 120])
                    )
                )
                {
                    $sg += 10;
                }
            }
        }
        if (isset($pls2_2[0]['phase']['0-1']))
        {
            if (in_array($pls2_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sg += 10;
                // 若此时，彼日落我3/6/9/10/11宫+8
                if (in_array($pls2_2[0]['in_house_id'], [3, 6, 9, 10, 11]))
                {
                    $sg += 8;
                }
            } elseif ($pls2_2[0]['phase']['0-1']['phase_e'] == 180)
            {
                $sg += 8;
                // 若此时，彼日落我3/6/9/10/11宫+8
                if (in_array($pls2_2[0]['in_house_id'], [3, 6, 9, 10, 11]))
                {
                    $sg += 8;
                }
            }
        }
        if (isset($pls2_2[0]['phase']['0-' . MC]) && $pls2_2[0]['phase']['0-' . MC]['phase_e'] == 0)
        {
            $sg += 8;
        }
        if (isset($pls2_2[5]['phase']['5-0']) || isset($pls2_2[6]['phase']['5-1']))
        {
            if (
                (
                    isset($pls2_2[5]['phase']['5-0'])
                    && $pls2_2[5]['phase']['5-0']['phase_e'] == 0
                )
                ||
                (
                    isset($pls2_2[5]['phase']['5-1'])
                    && $pls2_2[5]['phase']['5-1']['phase_e'] == 0
                )
            )
            {
                $sg += 10;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls2_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }
            } elseif (
                (
                    isset($pls2_2[5]['phase']['5-0'])
                    && ($pls2_2[5]['phase']['5-0']['phase_e'] == 60
                        || $pls2_2[5]['phase']['5-0']['phase_e'] == 120)
                )
                ||
                (
                    isset($pls2_2[5]['phase']['5-1'])
                    && ($pls2_2[5]['phase']['5-1']['phase_e'] == 60
                        || $pls2_2[5]['phase']['5-1']['phase_e'] == 120)
                )
            )
            {
                $sg += 7;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls2_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }
            } elseif (
                (
                    isset($pls2_2[5]['phase']['5-0'])
                    && $pls2_2[5]['phase']['5-0']['phase_e'] == 180
                )
                ||
                (
                    isset($pls2_2[5]['phase']['5-1'])
                    && $pls2_2[5]['phase']['5-1']['phase_e'] == 180
                )
            )
            {
                $sg += 3;
                // 若此时彼木落我3/6/9/10宫+6
                if (in_array($pls2_2[5]['in_house_id'], [3, 6, 9, 10]))
                {
                    $sg += 6;
                }
            }
        }
        if ($pls2_2[5]['in_house_id'] == 7)
        {
            $sg += 10;
        } elseif ($pls2_2[5]['in_house_id'] == 1)
        {
            $sg += 5;
        }
        if ($pls2_2[6]['in_house_id'] == 7)
        {
            $sg += 8;
        } elseif ($pls2_2[6]['in_house_id'] == 1)
        {
            $sg += 4;
        }
        if (
            ($foothold_2 >= 5 && $foothold_2_bad >= -2)
            &&
            (
                ($foothold_3_bad == 0 && $foothold_3 > 2)
                || ($foothold_3_bad >= -2 && $foothold_3 > 3.5)
            )
        )
        {
            $sg *= 1.5;
        } elseif (
            ($foothold_2 < 5 || $foothold_2_bad < -2)
            &&
            (
                ($foothold_3_bad != 0 || $foothold_3 <= 2)
                || ($foothold_3_bad < -2 || $foothold_3 <= 3.5)
            )
        )
        {
            $sg *= 0.5;
        }
        $score2['grow'] += $sg;

        // 物质
        // 彼日落我2宫+10，此时有非三王星的拱六分+5，合+6
        // 彼月落我2宫+12，此时有非三王星的拱六分+6，合+7
        // 彼金落我2宫+10，此时有非三王星的拱六分+5，合+6
        // 彼木落我2宫+8，此时有非三王星的拱六分+4，合+5
        // 彼水落我2宫且无刑冲相位+6
        // 彼火落我2宫且无刑冲相位+5
        // 彼木落我1/7宫但不合上升下降+5，此时若与我日月金星成冲合拱六分+5
        // 彼木合我上升下降+7，此时若与我日月金星成冲合拱六分+5
        // 彼金落我1/7宫但不合上升下降+5，此时若与我日月金星成冲合拱六分+5
        // 彼金合我上升下降+7，此时若与我日月金星成冲合拱六分+5
        for ($i = 0; $i < 6; $i++)
        {
            if ($pls1_2[$i]['in_house_id'] == 2)
            {
                $s1_phase_no789_60120 = false;
                $s1_phase_no789_0 = false;
                if (in_array($i, [0, 1, 3, 5]))
                {
                    if (
                        (
                            isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-2'])
                            && in_array($pls1_2[$i]['phase'][$i . '-2']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-3'])
                            && in_array($pls1_2[$i]['phase'][$i . '-3']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-4'])
                            && in_array($pls1_2[$i]['phase'][$i . '-4']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-5'])
                            && in_array($pls1_2[$i]['phase'][$i . '-5']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-6'])
                            && in_array($pls1_2[$i]['phase'][$i . '-6']['phase_e'], [60, 120])
                        )
                    )
                    {
                        $s1_phase_no789_60120 = true;
                    }
                    if (
                        (
                            isset($pls1_2[$i]['phase'][$i . '-0'])
                            && $pls1_2[$i]['phase'][$i . '-0']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-1'])
                            && $pls1_2[$i]['phase'][$i . '-1']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-2'])
                            && $pls1_2[$i]['phase'][$i . '-2']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-3'])
                            && $pls1_2[$i]['phase'][$i . '-3']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-4'])
                            && $pls1_2[$i]['phase'][$i . '-4']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-5'])
                            && $pls1_2[$i]['phase'][$i . '-5']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-6'])
                            && $pls1_2[$i]['phase'][$i . '-6']['phase_e'] == 0
                        )
                    )
                    {
                        $s1_phase_no789_0 = true;
                    }
                }
                if ($i == 0)
                {
                    $score1['substance'] += 10;
                    if ($s1_phase_no789_60120)
                    {
                        $score1['substance'] += 5;
                    }
                    if ($s1_phase_no789_0)
                    {
                        $score1['substance'] += 6;
                    }
                } elseif ($i == 1)
                {
                    $score1['substance'] += 12;
                    if ($s1_phase_no789_60120)
                    {
                        $score1['substance'] += 6;
                    }
                    if ($s1_phase_no789_0)
                    {
                        $score1['substance'] += 7;
                    }
                } elseif ($i == 2)
                {
                    $is_2_phase_90180 = false;
                    if (!empty($pls1_2[$i]['phase']))
                    {
                        foreach ($pls1_2[$i]['phase'] as $ps)
                        {
                            if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                            {
                                $is_2_phase_90180 = true;
                            }
                        }
                    }
                    if (!$is_2_phase_90180)
                    {
                        $score1['substance'] += 6;
                    }
                } elseif ($i == 3)
                {
                    $score1['substance'] += 10;
                    if ($s1_phase_no789_60120)
                    {
                        $score1['substance'] += 5;
                    }
                    if ($s1_phase_no789_0)
                    {
                        $score1['substance'] += 6;
                    }
                } elseif ($i == 4)
                {
                    $is_4_phase_90180 = false;
                    if (!empty($pls1_2[$i]['phase']))
                    {
                        foreach ($pls1_2[$i]['phase'] as $ps)
                        {
                            if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                            {
                                $is_4_phase_90180 = true;
                            }
                        }
                    }
                    if (!$is_4_phase_90180)
                    {
                        $score1['substance'] += 5;
                    }
                } elseif ($i == 5)
                {
                    $score1['substance'] += 8;
                    if ($s1_phase_no789_60120)
                    {
                        $score1['substance'] += 4;
                    }
                    if ($s1_phase_no789_0)
                    {
                        $score1['substance'] += 5;
                    }
                }
            }
            if ($i == 3 || $i == 5)
            {
                if (
                    (
                        $pls1_2[$i]['in_house_id'] == 1
                        &&
                        (
                            !isset($pls1_2[$i]['phase'][$i . '-' . ASC])
                            || !$pls1_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 0
                        )
                    )
                    ||
                    (
                        $pls1_2[$i]['in_house_id'] == 7
                        &&
                        (
                            !isset($pls1_2[$i]['phase'][$i . '-' . ASC])
                            || !$pls1_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 180
                        )
                    )
                )
                {
                    $score1['substance'] += 5;
                    if (
                        (
                            isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-3'])
                            && in_array($pls1_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120, 180])
                        )
                    )
                    {
                        $score1['substance'] += 5;
                    }
                }
                if (
                    (
                        isset($pls1_2[$i]['phase'][$i . '-' . ASC])
                        && $pls1_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 0
                    )
                    ||
                    (
                        isset($pls1_2[$i]['phase'][$i . '-' . ASC])
                        && $pls1_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 180
                    )
                )
                {
                    $score1['substance'] += 7;
                    if (
                        (
                            isset($pls1_2[$i]['phase'][$i . '-0'])
                            && in_array($pls1_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-1'])
                            && in_array($pls1_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls1_2[$i]['phase'][$i . '-3'])
                            && in_array($pls1_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120, 180])
                        )
                    )
                    {
                        $score1['substance'] += 5;
                    }
                }
            }
            if ($pls2_2[$i]['in_house_id'] == 2)
            {
                $s2_phase_no789_60120 = false;
                $s2_phase_no789_0 = false;
                if (in_array($i, [0, 1, 3, 5]))
                {
                    if (
                        (
                            isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-2'])
                            && in_array($pls2_2[$i]['phase'][$i . '-2']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-3'])
                            && in_array($pls2_2[$i]['phase'][$i . '-3']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-4'])
                            && in_array($pls2_2[$i]['phase'][$i . '-4']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-5'])
                            && in_array($pls2_2[$i]['phase'][$i . '-5']['phase_e'], [60, 120])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-6'])
                            && in_array($pls2_2[$i]['phase'][$i . '-6']['phase_e'], [60, 120])
                        )
                    )
                    {
                        $s2_phase_no789_60120 = true;
                    }
                    if (
                        (
                            isset($pls2_2[$i]['phase'][$i . '-0'])
                            && $pls2_2[$i]['phase'][$i . '-0']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-1'])
                            && $pls2_2[$i]['phase'][$i . '-1']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-2'])
                            && $pls2_2[$i]['phase'][$i . '-2']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-3'])
                            && $pls2_2[$i]['phase'][$i . '-3']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-4'])
                            && $pls2_2[$i]['phase'][$i . '-4']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-5'])
                            && $pls2_2[$i]['phase'][$i . '-5']['phase_e'] == 0
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-6'])
                            && $pls2_2[$i]['phase'][$i . '-6']['phase_e'] == 0
                        )
                    )
                    {
                        $s2_phase_no789_0 = true;
                    }
                }
                if ($i == 0)
                {
                    $score2['substance'] += 10;
                    if ($s2_phase_no789_60120)
                    {
                        $score2['substance'] += 5;
                    }
                    if ($s2_phase_no789_0)
                    {
                        $score2['substance'] += 6;
                    }
                } elseif ($i == 1)
                {
                    $score2['substance'] += 12;
                    if ($s2_phase_no789_60120)
                    {
                        $score2['substance'] += 6;
                    }
                    if ($s2_phase_no789_0)
                    {
                        $score2['substance'] += 7;
                    }
                } elseif ($i == 2)
                {
                    $is_2_phase_90180 = false;
                    if (!empty($pls2_2[$i]['phase']))
                    {
                        foreach ($pls2_2[$i]['phase'] as $ps)
                        {
                            if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                            {
                                $is_2_phase_90180 = true;
                            }
                        }
                    }
                    if (!$is_2_phase_90180)
                    {
                        $score2['substance'] += 6;
                    }
                } elseif ($i == 3)
                {
                    $score2['substance'] += 10;
                    if ($s2_phase_no789_60120)
                    {
                        $score2['substance'] += 5;
                    }
                    if ($s2_phase_no789_0)
                    {
                        $score2['substance'] += 6;
                    }
                } elseif ($i == 4)
                {
                    $is_4_phase_90180 = false;
                    if (!empty($pls2_2[$i]['phase']))
                    {
                        foreach ($pls2_2[$i]['phase'] as $ps)
                        {
                            if ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                            {
                                $is_4_phase_90180 = true;
                            }
                        }
                    }
                    if (!$is_4_phase_90180)
                    {
                        $score2['substance'] += 5;
                    }
                } elseif ($i == 5)
                {
                    $score2['substance'] += 8;
                    if ($s2_phase_no789_60120)
                    {
                        $score2['substance'] += 4;
                    }
                    if ($s2_phase_no789_0)
                    {
                        $score2['substance'] += 5;
                    }
                }
            }
            if ($i == 3 || $i == 5)
            {
                if (
                    (
                        $pls2_2[$i]['in_house_id'] == 1
                        &&
                        (
                            !isset($pls2_2[$i]['phase'][$i . '-' . ASC])
                            || !$pls2_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 0
                        )
                    )
                    ||
                    (
                        $pls2_2[$i]['in_house_id'] == 7
                        &&
                        (
                            !isset($pls2_2[$i]['phase'][$i . '-' . ASC])
                            || !$pls2_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 180
                        )
                    )
                )
                {
                    $score2['substance'] += 5;
                    if (
                        (
                            isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-3'])
                            && in_array($pls2_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120, 180])
                        )
                    )
                    {
                        $score2['substance'] += 5;
                    }
                }
                if (
                    (
                        isset($pls2_2[$i]['phase'][$i . '-' . ASC])
                        && $pls2_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 0
                    )
                    ||
                    (
                        isset($pls2_2[$i]['phase'][$i . '-' . ASC])
                        && $pls2_2[$i]['phase'][$i . '-' . ASC]['phase_e'] == 180
                    )
                )
                {
                    $score2['substance'] += 7;
                    if (
                        (
                            isset($pls2_2[$i]['phase'][$i . '-0'])
                            && in_array($pls2_2[$i]['phase'][$i . '-0']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-1'])
                            && in_array($pls2_2[$i]['phase'][$i . '-1']['phase_e'], [0, 60, 120, 180])
                        )
                        ||
                        (
                            isset($pls2_2[$i]['phase'][$i . '-3'])
                            && in_array($pls2_2[$i]['phase'][$i . '-3']['phase_e'], [0, 60, 120, 180])
                        )
                    )
                    {
                        $score2['substance'] += 5;
                    }
                }
            }
        }

        // 关爱
        // 彼月合我上升、天底、下降+57，合我中天+30
        // 彼月拱我上升、天底、下降+24
        // 彼月不合我轴，但落我1/4/7宫+35
        // 彼月合拱六分我月+58，冲+30
        // 彼月合拱六分我日+58，冲+30
        // 彼月合拱六分我金+30，冲+10
        // 彼月合拱六分我1、4宫宫内个人星+26
        // 1彼金与我火星合拱六分+33，冲+18，刑+7（如以上不标数字的的各项得分合为零，则以下标数字的各项得分折半）
        // 2彼金与我金星合拱六分+32，冲+17
        // 3彼金与我太阳合拱六分+29，冲+15，刑+6
        // 4彼金与我月亮合拱六分+31，冲+15，刑+6
        // 5彼金与我水星合拱六分+14
        // 6彼金合我升降天底+30
        $a = 0;
        $b = 0;
        if (!empty($pls1_2[1]['phase']))
        {
            $is_060120 = false;// 是否合拱六分个人星 且落1/4宫
            $is_4zhou_0 = false;// 是否合轴
            foreach ($pls1_2[1]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 58;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 30;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 58;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 30;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 10;
                    }
                }
                if (in_array($ps['id'], [ASC, MC]) && in_array($ps['phase_e'], [0, 180]))
                {
                    $is_4zhou_0 = true;
                }
                if (in_array($ps['id'], [ASC, MC]))
                {
                    if (
                        ($ps['id'] == ASC && in_array($ps['phase_e'], [0, 180]))
                        || ($ps['id'] == MC && $ps['phase_e'] == 180)
                    )
                    {
                        $a += 57;
                    } elseif ($ps['id'] == MC && $ps['phase_e'] == 0)
                    {
                        $a += 30;
                    }
                    if (
                        (
                            $ps['id'] == ASC
                            && in_array($ps['phase_e'], [60, 120])
                        )
                        &&
                        (
                            $ps['id'] == MC
                            && $ps['phase_e'] == 60
                        )
                    )
                    {
                        $a += 24;
                    }
                }
                if (
                    $ps['id'] < 5
                    && in_array($pls1_2[$ps['id']]['in_house_id'], [1, 4])
                    && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $is_060120 = true;
                }
            }
            if ($is_060120)
            {
                $a += 26;
            }
        }
        if (!empty($pls1_2[3]['phase']))
        {
            foreach ($pls1_2[3]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 29;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 15;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 6;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 31;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 15;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 6;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 14;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 32;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 17;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 33;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 18;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 7;
                    }
                } elseif ($ps['id'] == ASC || $ps['id'] == MC)
                {
                    if (
                        (
                            $ps['id'] == ASC
                            && in_array($ps['phase_e'], [0, 180])
                        )
                        ||
                        (
                            $ps['id'] == MC
                            && $ps['phase_e'] == 180
                        )
                    )
                    {
                        $b += 30;
                    }
                }
            }
        }
        if ($a == 0)
        {
            $score1['care'] += ($a + $b / 2);
//            $score1['care'] += round($a + $b/2);
        } else
        {
            $score1['care'] += ($a + $b);
        }
        $a = 0;
        $b = 0;
        if (!empty($pls2_2[1]['phase']))
        {
            $is_060120 = false;// 是否合拱六分个人星 且落1/4宫
            $is_4zhou_0 = false;// 是否合轴
            foreach ($pls2_2[1]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 58;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 30;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 58;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 30;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $a += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $a += 10;
                    }
                }
                if (in_array($ps['id'], [ASC, MC]) && in_array($ps['phase_e'], [0, 180]))
                {
                    $is_4zhou_0 = true;
                }
                if (in_array($ps['id'], [ASC, MC]))
                {
                    if (
                        ($ps['id'] == ASC && in_array($ps['phase_e'], [0, 180]))
                        || ($ps['id'] == MC && $ps['phase_e'] == 180)
                    )
                    {
                        $a += 57;
                    } elseif ($ps['id'] == MC && $ps['phase_e'] == 0)
                    {
                        $a += 30;
                    }
                    if (
                        (
                            $ps['id'] == ASC
                            && in_array($ps['phase_e'], [60, 120])
                        )
                        &&
                        (
                            $ps['id'] == MC
                            && $ps['phase_e'] == 60
                        )
                    )
                    {
                        $a += 24;
                    }
                }
                if (
                    $ps['id'] < 5
                    && in_array($pls2_2[$ps['id']]['in_house_id'], [1, 4])
                    && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $is_060120 = true;
                }
            }
            if ($is_060120)
            {
                $a += 26;
            }
        }
        if (!empty($pls2_2[3]['phase']))
        {
            foreach ($pls2_2[3]['phase'] as $ps)
            {
                if ($ps['id'] == 0)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 29;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 15;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 6;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 31;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 15;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 6;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 14;
                    }
                } elseif ($ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 32;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 17;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $b += 33;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $b += 18;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $b += 7;
                    }
                } elseif ($ps['id'] == ASC || $ps['id'] == MC)
                {
                    if (
                        (
                            $ps['id'] == ASC
                            && in_array($ps['phase_e'], [0, 180])
                        )
                        ||
                        (
                            $ps['id'] == MC
                            && $ps['phase_e'] == 180
                        )
                    )
                    {
                        $b += 30;
                    }
                }
            }
        }
        if ($a == 0)
        {
            $score2['care'] += ($a + $b / 2);
//            $score2['care'] += round($a + $b/2);
        } else
        {
            $score2['care'] += ($a + $b);
        }

        // 激励 motivate
        // 彼日合我四轴+30，拱四轴+10
        // 彼日合我日+35，拱六分我日+28，冲我日+10
        // 彼日合我月+30，拱六分我月+24，冲我月+10
        // 彼日合我火+34，拱六分我火+28，冲我火+10
        // 彼日合拱六分我金水+15
        // 若以上得分不为零，彼火合拱六分我日月之一+20，彼火合拱六分我金水火之一+12，彼火合我四轴+15
        $sm = 0;
        if (!empty($pls1_2[0]['phase']))
        {
            foreach ($pls1_2[0]['phase'] as $ps)
            {
                if ($ps['id'] == ASC || $ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $sm += 30;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 35;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 28;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 30;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 24;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 2 || $ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 15;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 34;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 28;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                }
            }
            if ($sm != 0 && !empty($pls1_2[4]['phase']))
            {
                foreach ($pls1_2[4]['phase'] as $ps)
                {
                    if (($ps['id'] == 0 || $ps['id'] == 1)
                        && in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 20;
                    } elseif (($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                        && in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 12;
                    } elseif (($ps['id'] == ASC || $ps['id'] == MC || $ps['id'] == 4)
                        && in_array($ps['phase_e'], [0, 180]))
                    {
                        $sm += 15;
                    }
                }
            }
        }
        $score1['motivate'] += $sm;
        $sm = 0;
        if (!empty($pls2_2[0]['phase']))
        {
            foreach ($pls2_2[0]['phase'] as $ps)
            {
                if ($ps['id'] == ASC || $ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $sm += 30;
                    } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 35;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 28;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 30;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 24;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                } elseif ($ps['id'] == 2 || $ps['id'] == 3)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 15;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sm += 34;
                    } elseif (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sm += 28;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sm += 10;
                    }
                }
            }
            if ($sm != 0 && !empty($pls2_2[4]['phase']))
            {
                foreach ($pls2_2[4]['phase'] as $ps)
                {
                    if (($ps['id'] == 0 || $ps['id'] == 1)
                        && in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 20;
                    } elseif (($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                        && in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sm += 12;
                    } elseif (($ps['id'] == ASC || $ps['id'] == MC || $ps['id'] == 4)
                        && in_array($ps['phase_e'], [0, 180]))
                    {
                        $sm += 15;
                    }
                }
            }
        }
        $score2['motivate'] += $sm;

        // 安全 relieved
        // 基数 30
        // 我月与彼金木合+40，拱+30，冲+10，六分+25，刑-5
        // 我月与彼日月合+45，拱+35，冲+15，六分+30，刑-20
        // 我月与彼水合拱六分+20，刑-20冲-10
        // 我月与彼火合-5，拱六分+0，刑冲-30
        // 我月与彼土合-10，拱六分+0（若我月落对方8/12宫或有任何刑冲改为-5），刑冲-40
        // 我月本无三王相位，与彼月三王合-5，拱六分-0，刑冲-20
        // 我月落对方8宫-20,12宫-30，6宫-10
        // 我月落彼1/4/5/7宫+10
        $sr = 30;
        if (!empty($pls1[1]['phase']))
        {
            $is_phase90180_1 = false;
            if ($pls1[1]['in_house_id'] == 8 || $pls1[1]['in_house_id'] == 12)
            {
                foreach ($pls1[1]['phase'] as $ps)
                {
                    if (in_array($ps['phase_e'], [90, 180]))
                    {
                        $is_phase90180_1 = true;
                    }
                }
            }
            foreach ($pls1[1]['phase'] as $ps)
            {
                if ($ps['id'] == 3 || $ps['id'] == 5)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sr += 40;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sr += 25;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 5;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sr += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr += 10;
                    }
                } elseif ($ps['id'] == 0 || $ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sr += 45;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sr += 30;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 20;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sr += 35;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr += 15;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sr += 20;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 20;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr -= 10;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sr += 0;
                    } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $sr -= 30;
                    } elseif ($ps['phase_e'] == 0)
                    {
                        $sr -= 5;
                    }
                } elseif ($ps['id'] == 6)
                {
                    if (in_array($ps['phase_e'], [60, 120]))
                    {
                        if ($is_phase90180_1)
                        {
                            $sr -= 5;
                        } else
                        {
                            $sr += 0;
                        }
                    } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $sr -= 40;
                    } elseif ($ps['phase_e'] == 0)
                    {
                        $sr -= 10;
                    }
                } elseif ($ps['id'] == 7 || $ps['id'] == 8 || $ps['id'] == 9)
                {
                    if (
                        !isset($pls1[1]['or_phase']['1-7'])
                        && !isset($pls1[1]['or_phase']['1-8'])
                        && !isset($pls1[1]['or_phase']['1-9'])
                    )
                    {
                        if ($ps['phase_e'] == 0)
                        {
                            $sr -= 5;
                        } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                        {
                            $sr -= 0;
                        } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                        {
                            $sr -= 20;
                        }
                    }
                }
            }
        }
        if ($pls2_2[1]['in_house_id'] == 8)
        {
            $sr -= 20;
        } elseif ($pls2_2[1]['in_house_id'] == 12)
        {
            $sr -= 30;
        } elseif ($pls2_2[1]['in_house_id'] == 6)
        {
            $sr -= 10;
        } elseif (in_array($pls2_2[1]['in_house_id'], [1, 4, 5, 7]))
        {
            $sr += 10;
        }
        $score1['relieved'] += $sr;
        $sr = 30;
        if (!empty($pls2[1]['phase']))
        {
            $is_phase90180_1 = false;
            if ($pls2[1]['in_house_id'] == 8 || $pls2[1]['in_house_id'] == 12)
            {
                foreach ($pls2[1]['phase'] as $ps)
                {
                    if (in_array($ps['phase_e'], [90, 180]))
                    {
                        $is_phase90180_1 = true;
                    }
                }
            }
            foreach ($pls2[1]['phase'] as $ps)
            {
                if ($ps['id'] == 3 || $ps['id'] == 5)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sr += 40;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sr += 25;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 5;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sr += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr += 10;
                    }
                } elseif ($ps['id'] == 0 || $ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sr += 45;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sr += 30;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 20;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sr += 35;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr += 15;
                    }
                } elseif ($ps['id'] == 2)
                {
                    if (in_array($ps['phase_e'], [0, 60, 120]))
                    {
                        $sr += 20;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sr -= 20;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sr -= 10;
                    }
                } elseif ($ps['id'] == 4)
                {
                    if (in_array($ps['phase_e'], [60, 120]))
                    {
                        $sr += 0;
                    } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $sr -= 30;
                    } elseif ($ps['phase_e'] == 0)
                    {
                        $sr -= 5;
                    }
                } elseif ($ps['id'] == 6)
                {
                    if (in_array($ps['phase_e'], [60, 120]))
                    {
                        if ($is_phase90180_1)
                        {
                            $sr -= 5;
                        } else
                        {
                            $sr += 0;
                        }
                    } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                    {
                        $sr -= 40;
                    } elseif ($ps['phase_e'] == 0)
                    {
                        $sr -= 10;
                    }
                } elseif ($ps['id'] == 7 || $ps['id'] == 8 || $ps['id'] == 9)
                {
                    if (
                        !isset($pls2[1]['or_phase']['1-7'])
                        && !isset($pls2[1]['or_phase']['1-8'])
                        && !isset($pls2[1]['or_phase']['1-9'])
                    )
                    {
                        if ($ps['phase_e'] == 0)
                        {
                            $sr -= 5;
                        } elseif ($ps['phase_e'] == 60 || $ps['phase_e'] == 120)
                        {
                            $sr -= 0;
                        } elseif ($ps['phase_e'] == 90 || $ps['phase_e'] == 180)
                        {
                            $sr -= 20;
                        }
                    }
                }
            }
        }
        if ($pls1_2[1]['in_house_id'] == 8)
        {
            $sr -= 20;
        } elseif ($pls1_2[1]['in_house_id'] == 12)
        {
            $sr -= 30;
        } elseif ($pls1_2[1]['in_house_id'] == 6)
        {
            $sr -= 10;
        } elseif (in_array($pls1_2[1]['in_house_id'], [1, 4, 5, 7]))
        {
            $sr += 10;
        }
        $score2['relieved'] += $sr;


        // 幸运 luck
        // 对方木星合自己上升或下降+60
        // 对方木星合自己中天或天底+50
        // 对方木星合自己太阳+60
        // 彼木拱己日+40
        // 彼木六分己日+30
        // 彼木冲己日+40
        // 彼木刑己日+25
        // 彼木合己月+45
        // 彼木拱己月+30，六分己月+22，冲月+30，刑月+20
        // 彼木合己金水火+18
        // 彼木拱己金+12，六分+8，冲+12，刑+12
        // 彼木不合轴落我1宫+25，4/7/10宫+20，5/9/11宫+15
        // 彼日落我11宫与我月（日）成合拱六分相+35（+20）
        // 彼日落我10宫与我月（日）成合拱六分相+30（+18）
        // 彼木拱合六分我1/4/7/10/11宫宫内星+15（不叠加）
        $sl = 0;
        $is_phase0_5 = false;
        $is_phase060120_house14710 = false;
        if (!empty($pls1_2[5]['phase']))
        {
            foreach ($pls1_2[5]['phase'] as $ps)
            {
                if (
                    in_array($pls1[$ps['id']]['in_house_id'], [1, 4, 7, 10])
                    && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $is_phase060120_house14710 = true;
                }
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 60;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sl += 30;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sl += 25;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sl += 40;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sl += 40;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 45;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sl += 22;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sl += 20;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sl += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sl += 30;
                    }
                } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 18;
                    } elseif ($ps['phase_e'] == 120 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    } elseif ($ps['phase_e'] == 60 && $ps['id'] == 3)
                    {
                        $sl += 8;
                    } elseif ($ps['phase_e'] == 180 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    } elseif ($ps['phase_e'] == 90 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $is_phase0_5 = true;
                        $sl += 60;
                    }
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $is_phase0_5 = true;
                        $sl += 50;
                    }
                }
            }
            if ($is_phase060120_house14710) $sl += 15;
        }
        if (!$is_phase0_5)
        {
            if ($pls1_2[5]['in_house_id'] == 1)
            {
                $sl += 25;
            } elseif (in_array($pls1_2[5]['in_house_id'], [4, 7, 10]))
            {
                $sl += 20;
            } elseif (in_array($pls1_2[5]['in_house_id'], [5, 9, 11]))
            {
                $sl += 15;
            }
        }
        if ($pls1_2[0]['in_house_id'] == 11)
        {
            if (isset($pls1_2[0]['phase']['0-0'])
                && in_array($pls1_2[0]['phase']['0-0']['phase_e'], [0, 60, 120]))
            {
                $sl += 20;
            }
            if (isset($pls1_2[0]['phase']['0-1'])
                && in_array($pls1_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sl += 35;
            }
        } elseif ($pls1_2[0]['in_house_id'] == 10)
        {
            if (isset($pls1_2[0]['phase']['0-0'])
                && in_array($pls1_2[0]['phase']['0-0']['phase_e'], [0, 60, 120]))
            {
                $sl += 18;
            }
            if (isset($pls1_2[0]['phase']['0-1'])
                && in_array($pls1_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sl += 30;
            }
        }
        $score1['luck'] += $sl;

        $sl = 0;
        $is_phase0_5 = false;
        $is_phase060120_house14710 = false;
        if (!empty($pls2_2[5]['phase']))
        {
            foreach ($pls2_2[5]['phase'] as $ps)
            {
                if (
                    in_array($pls2[$ps['id']]['in_house_id'], [1, 4, 7, 10])
                    && in_array($ps['phase_e'], [0, 60, 120])
                )
                {
                    $is_phase060120_house14710 = true;
                }
                if ($ps['id'] == 0)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 60;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sl += 30;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sl += 25;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sl += 40;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sl += 40;
                    }
                } elseif ($ps['id'] == 1)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 45;
                    } elseif ($ps['phase_e'] == 60)
                    {
                        $sl += 22;
                    } elseif ($ps['phase_e'] == 90)
                    {
                        $sl += 20;
                    } elseif ($ps['phase_e'] == 120)
                    {
                        $sl += 30;
                    } elseif ($ps['phase_e'] == 180)
                    {
                        $sl += 30;
                    }
                } elseif ($ps['id'] == 2 || $ps['id'] == 3 || $ps['id'] == 4)
                {
                    if ($ps['phase_e'] == 0)
                    {
                        $sl += 18;
                    } elseif ($ps['phase_e'] == 120 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    } elseif ($ps['phase_e'] == 60 && $ps['id'] == 3)
                    {
                        $sl += 8;
                    } elseif ($ps['phase_e'] == 180 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    } elseif ($ps['phase_e'] == 90 && $ps['id'] == 3)
                    {
                        $sl += 12;
                    }
                } elseif ($ps['id'] == ASC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $is_phase0_5 = true;
                        $sl += 60;
                    }
                } elseif ($ps['id'] == MC)
                {
                    if ($ps['phase_e'] == 0 || $ps['phase_e'] == 180)
                    {
                        $is_phase0_5 = true;
                        $sl += 50;
                    }
                }
            }
            if ($is_phase060120_house14710) $sl += 15;
        }
        if (!$is_phase0_5)
        {
            if ($pls2_2[5]['in_house_id'] == 1)
            {
                $sl += 25;
            } elseif (in_array($pls2_2[5]['in_house_id'], [4, 7, 10]))
            {
                $sl += 20;
            } elseif (in_array($pls2_2[5]['in_house_id'], [5, 9, 11]))
            {
                $sl += 15;
            }
        }
        if ($pls2_2[0]['in_house_id'] == 11)
        {
            if (isset($pls2_2[0]['phase']['0-0'])
                && in_array($pls2_2[0]['phase']['0-0']['phase_e'], [0, 60, 120]))
            {
                $sl += 20;
            }
            if (isset($pls2_2[0]['phase']['0-1'])
                && in_array($pls2_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sl += 35;
            }
        } elseif ($pls2_2[0]['in_house_id'] == 10)
        {
            if (isset($pls2_2[0]['phase']['0-0'])
                && in_array($pls2_2[0]['phase']['0-0']['phase_e'], [0, 60, 120]))
            {
                $sl += 18;
            }
            if (isset($pls2_2[0]['phase']['0-1'])
                && in_array($pls2_2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
            {
                $sl += 30;
            }
        }
        $score2['luck'] += $sl;

        $score1['grow'] *= 2;
        $score1['substance'] *= 2.5;
        $score1['care'] *= 0.8;
        $score1['motivate'] *= 1;
        $score1['relieved'] *= 1;
        $score1['luck'] *= 0.8;
        $score1['grow'] = $score1['grow'] > 100 ? 100 : ($score1['grow'] < 0 ? 0 : $score1['grow']);
        $score1['substance'] = $score1['substance'] > 100 ? 100 : ($score1['substance'] < 0 ? 0 : $score1['substance']);
        $score1['care'] = $score1['care'] > 100 ? 100 : ($score1['care'] < 0 ? 0 : $score1['care']);
        $score1['motivate'] = $score1['motivate'] > 100 ? 100 : ($score1['motivate'] < 0 ? 0 : $score1['motivate']);
        $score1['relieved'] = $score1['relieved'] > 100 ? 100 : ($score1['relieved'] < 0 ? 0 : $score1['relieved']);
        $score1['luck'] = $score1['luck'] > 100 ? 100 : ($score1['luck'] < 0 ? 0 : $score1['luck']);

        $score2['grow'] *= 2;
        $score2['substance'] *= 2.5;
        $score2['care'] *= 0.8;
        $score2['motivate'] *= 1;
        $score2['relieved'] *= 1;
        $score2['luck'] *= 0.8;
        $score2['grow'] = $score2['grow'] > 100 ? 100 : ($score2['grow'] < 0 ? 0 : $score2['grow']);
        $score2['substance'] = $score2['substance'] > 100 ? 100 : ($score2['substance'] < 0 ? 0 : $score2['substance']);
        $score2['care'] = $score2['care'] > 100 ? 100 : ($score2['care'] < 0 ? 0 : $score2['care']);
        $score2['motivate'] = $score2['motivate'] > 100 ? 100 : ($score2['motivate'] < 0 ? 0 : $score2['motivate']);
        $score2['relieved'] = $score2['relieved'] > 100 ? 100 : ($score2['relieved'] < 0 ? 0 : $score2['relieved']);
        $score2['luck'] = $score2['luck'] > 100 ? 100 : ($score2['luck'] < 0 ? 0 : $score2['luck']);


        #--------------------------------------------------------------------------#
        #--------------------------------------------------------------------------#
        #-------------------------------假如恋爱-------------------------------------#
        #--------------------------------------------------------------------------#
        #--------------------------------------------------------------------------#
        #--------------------------------------------------------------------------#
//        $attract // 吸引指数
//        $chat// 沟通指数
//        $passion// 激情指数
//        $benefit // 亲密指数
//        $happy// 愉悦指数
//        $probTobeLover// 缘分指数
        // 沟通、激情、亲密、吸引、缘分均不低于50，且其中至少两项高于60
        $val_50more = 0;
        if ($attract > 60) $val_50more++;
        if ($chat > 60) $val_50more++;
        if ($passion > 60) $val_50more++;
        if ($benefit > 60) $val_50more++;
        if ($probTobeLover > 60) $val_50more++;
        $if_love = '';
        $if_love_status = 1;  // 1今生有缘  2 假如恋爱
        $total = $attract + $passion + $benefit + $chat + $happy + $probTobeLover;
        // 今生有缘
        if (
            $benefit < 20
            &&
            (
                (
                    isset($pls1[7]['phase']['7-' . ASC])
                    && in_array($pls1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
                ||
                (
                    isset($pls1[7]['phase']['7-' . MC])
                    && in_array($pls1[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                )
                ||
                (
                    isset($pls2[7]['phase']['7-' . ASC])
                    && in_array($pls2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                )
                ||
                (
                    isset($pls2[7]['phase']['7-' . MC])
                    && in_array($pls2[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                )
                ||
                (
                    isset($pls1[0]['phase']['0-7'])
                    && isset($pls2[0]['phase']['0-7'])
                )
                ||
                (
                    isset($pls1[1]['phase']['1-7'])
                    && isset($pls2[1]['phase']['1-7'])
                )
            )
        )
        {
            $if_love = '总是忽远忽近，谁能明白我心';
        }
        if ($benefit > 60 && $attract < 30 && $chat < 30 && $passion < 30 && $happy < 40)
        {
            $if_love = '看似相濡以沫，实则苦中作乐';
        }
        if (
            (
                isset($pls1[0]['phase']['0-4']) && in_array($pls1[0]['phase']['0-4']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls1[1]['phase']['1-4']) && in_array($pls1[1]['phase']['1-4']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls1[4]['phase']['4-' . ASC]) && in_array($pls1[4]['phase']['4-' . ASC]['phase_e'], [0, 180])
            )
            ||
            (
                isset($pls1[4]['phase']['4-' . MC]) && in_array($pls1[4]['phase']['4-' . MC]['phase_e'], [0, 180])
            )
            ||
            (
                isset($pls2[0]['phase']['0-4']) && in_array($pls2[0]['phase']['0-4']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls2[1]['phase']['1-4']) && in_array($pls2[1]['phase']['1-4']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls2[4]['phase']['4-' . ASC]) && in_array($pls2[4]['phase']['4-' . ASC]['phase_e'], [0, 180])
            )
            ||
            (
                isset($pls2[4]['phase']['4-' . MC]) && in_array($pls2[4]['phase']['4-' . MC]['phase_e'], [0, 180])
            )

        )
        {
            if (
                (
                    (
                        isset($pls1[0]['or_phase']['0-4']) || isset($pls1[1]['or_phase']['1-4'])
                    )
                    ||
                    (
                        $pls1[4]['in_sign_id'] == 1 || $pls1[4]['in_sign_id'] == 5
                    )
                    ||
                    (
                        isset($pls1[4]['or_phase']['4-' . ASC])
                        && in_array($pls1[4]['or_phase']['4-' . ASC]['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[4]['or_phase']['4-' . MC])
                        && in_array($pls1[4]['or_phase']['4-' . MC]['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[4]['or_phase']['4-7'])
                        && in_array($pls1[4]['or_phase']['4-7']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls1[4]['or_phase']['4-9'])
                        && in_array($pls1[4]['or_phase']['4-9']['phase_e'], [90, 180])
                    )
                )
                &&
                (
                (
                    (
                        isset($pls2[0]['or_phase']['0-4']) || isset($pls2[1]['or_phase']['1-4'])
                    )
                    ||
                    (
                        $pls2[4]['in_sign_id'] == 1 || $pls2[4]['in_sign_id'] == 5
                    )
                    ||
                    (
                        isset($pls2[4]['or_phase']['4-' . ASC])
                        && in_array($pls2[4]['or_phase']['4-' . ASC]['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[4]['or_phase']['4-' . MC])
                        && in_array($pls2[4]['or_phase']['4-' . MC]['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[4]['or_phase']['4-7'])
                        && in_array($pls2[4]['or_phase']['4-7']['phase_e'], [90, 180])
                    )
                    ||
                    (
                        isset($pls2[4]['or_phase']['4-9'])
                        && in_array($pls2[4]['or_phase']['4-9']['phase_e'], [90, 180])
                    )
                )
                )
            )
            {
                $if_love = '脾气火烧火燎，感情一架打跑';// 20180205
            }

        }
        if (
            (
                isset($pls1[6]['phase']['6-0']) && in_array($pls1[6]['phase']['6-0']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls1[6]['phase']['6-1']) && in_array($pls1[6]['phase']['6-1']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls2[6]['phase']['6-0']) && in_array($pls2[6]['phase']['6-0']['phase_e'], [90, 180])
            )
            ||
            (
                isset($pls2[6]['phase']['6-1']) && in_array($pls2[6]['phase']['6-1']['phase_e'], [90, 180])
            )
        )
        {
            $main_planet = $this->getTheMainPhase($data1, $data2)['influ']['c'];
            $keyc = array_search(max($main_planet), $main_planet);// 内外相加后
            if ($keyc == 6)
            {
                $if_love = '平安无事靠忍，舒畅开心靠狠';
            }
        }
        $phase_01234_090180_num = 0;
        $phase_01234_90180_num = 0;
        for ($i = 0; $i < 5; $i++)
        {
            for ($j = 0; $j < 7; $j++)
            {
                if (
                    isset($pls1[$i]['phase'][$i . '-' . $j])
                    && in_array($pls1[$i]['phase'][$i . '-' . $j]['phase_e'], [0, 90, 180])
                )
                {
                    $phase_01234_090180_num++;
                }
                if (
                    $i != $j
                    && isset($pls2[$i]['phase'][$i . '-' . $j])
                    && in_array($pls2[$i]['phase'][$i . '-' . $j]['phase_e'], [0, 90, 180])
                )
                {
                    $phase_01234_090180_num++;
                }
                if ($j > 4) continue;
                if (
                    isset($pls1[$i]['phase'][$i . '-' . $j])
                    && in_array($pls1[$i]['phase'][$i . '-' . $j]['phase_e'], [90, 180])
                )
                {
                    $phase_01234_90180_num++;
                }
                if (
                    $i != $j
                    && isset($pls2[$i]['phase'][$i . '-' . $j])
                    && in_array($pls2[$i]['phase'][$i . '-' . $j]['phase_e'], [90, 180])
                )
                {
                    $phase_01234_90180_num++;
                }
            }
        }
        if ($phase_01234_090180_num == 0)
        {
            $if_love = '劝君不忘初心，平平淡淡是真';
        }
        if (
            (
                $phase_01234_90180_num == 0
                ||
                (
                    $phase_01234_90180_num == 1
                    &&
                    (
                        (isset($pls1[0]['phase']['0-1']) && $pls1[0]['phase']['0-1']['phase_e'] == 180)
                        || (isset($pls2[0]['phase']['0-1']) && $pls2[0]['phase']['0-1']['phase_e'] == 180)
                    )
                )
                ||
                (
                    $phase_01234_90180_num == 2
                    && isset($pls1[0]['phase']['0-1']) && $pls1[0]['phase']['0-1']['phase_e'] == 180
                    && isset($pls2[0]['phase']['0-1']) && $pls2[0]['phase']['0-1']['phase_e'] == 180
                )
            )
            &&
            (
                (
                    (
                        isset($pls1[0]['phase']['0-' . ASC])
                        && in_array($pls1[0]['phase']['0-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[0]['phase']['0-' . MC])
                        && in_array($pls1[0]['phase']['0-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-' . ASC])
                        && in_array($pls1[1]['phase']['1-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-' . MC])
                        && in_array($pls1[1]['phase']['1-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-' . ASC])
                        && in_array($pls1[3]['phase']['3-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-' . MC])
                        && in_array($pls1[3]['phase']['3-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[5]['phase']['5-' . ASC])
                        && in_array($pls1[5]['phase']['5-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[5]['phase']['5-' . MC])
                        && in_array($pls1[5]['phase']['5-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[0]['phase']['0-' . ASC])
                        && in_array($pls2[0]['phase']['0-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[0]['phase']['0-' . MC])
                        && in_array($pls2[0]['phase']['0-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-' . ASC])
                        && in_array($pls2[1]['phase']['1-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-' . MC])
                        && in_array($pls2[1]['phase']['1-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-' . ASC])
                        && in_array($pls2[3]['phase']['3-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-' . MC])
                        && in_array($pls2[3]['phase']['3-' . MC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[5]['phase']['5-' . ASC])
                        && in_array($pls2[5]['phase']['5-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[5]['phase']['5-' . MC])
                        && in_array($pls2[5]['phase']['5-' . MC]['phase_e'], [0, 180])
                    )
                )
                &&
                (
                    (
                        !isset($pls1[4]['phase']['4-' . ASC])
                        || in_array($pls1[4]['phase']['4-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[4]['phase']['4-' . MC])
                        || !in_array($pls1[4]['phase']['4-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[6]['phase']['6-' . ASC])
                        || in_array($pls1[6]['phase']['6-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[6]['phase']['6-' . MC])
                        || !in_array($pls1[6]['phase']['6-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[7]['phase']['7-' . ASC])
                        || in_array($pls1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[7]['phase']['7-' . MC])
                        || !in_array($pls1[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[8]['phase']['8-' . ASC])
                        || in_array($pls1[8]['phase']['8-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[8]['phase']['8-' . MC])
                        || !in_array($pls1[8]['phase']['8-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[9]['phase']['9-' . ASC])
                        || in_array($pls1[9]['phase']['9-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls1[9]['phase']['9-' . MC])
                        || !in_array($pls1[9]['phase']['9-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[4]['phase']['4-' . ASC])
                        || in_array($pls2[4]['phase']['4-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[4]['phase']['4-' . MC])
                        || !in_array($pls2[4]['phase']['4-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[6]['phase']['6-' . ASC])
                        || in_array($pls2[6]['phase']['6-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[6]['phase']['6-' . MC])
                        || !in_array($pls2[6]['phase']['6-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[7]['phase']['7-' . ASC])
                        || in_array($pls2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[7]['phase']['7-' . MC])
                        || !in_array($pls2[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[8]['phase']['8-' . ASC])
                        || in_array($pls2[8]['phase']['8-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[8]['phase']['8-' . MC])
                        || !in_array($pls2[8]['phase']['8-' . MC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[9]['phase']['9-' . ASC])
                        || in_array($pls2[9]['phase']['9-' . ASC]['phase_e'], [0, 180])
                    )
                    &&
                    (
                        !isset($pls2[9]['phase']['9-' . MC])
                        || !in_array($pls2[9]['phase']['9-' . MC]['phase_e'], [0, 180])
                    )
                )
            )
            &&
            (
                (
                    (!isset($pls1[0]['phase']['0-1']) || $pls1[0]['phase']['0-1']['phase_e'] != 90)
                    && (!isset($pls2[0]['phase']['0-1']) || $pls2[0]['phase']['0-1']['phase_e'] != 90)
                )
                ||
                (
                    (!isset($pls2[0]['phase']['0-1']) || $pls2[0]['phase']['0-1']['phase_e'] != 90)
                    && (!isset($pls1[0]['phase']['0-1']) || $pls1[0]['phase']['0-1']['phase_e'] != 90)
                )
            )
            &&
            (
                (
                    (
                        isset($pls1[3]['phase']['3-0'])
                        && in_array($pls1[3]['phase']['3-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-1'])
                        && in_array($pls1[3]['phase']['3-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-3'])
                        && in_array($pls1[3]['phase']['3-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-4'])
                        && in_array($pls1[3]['phase']['3-4']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-5'])
                        && in_array($pls1[3]['phase']['3-5']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-' . ASC])
                        && in_array($pls1[3]['phase']['3-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['phase']['3-' . MC])
                        && in_array($pls1[3]['phase']['3-' . MC]['phase_e'], [0, 180])
                    )
                )
                &&
                (
                    (
                        isset($pls2[3]['phase']['3-0'])
                        && in_array($pls2[3]['phase']['3-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-1'])
                        && in_array($pls2[3]['phase']['3-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-3'])
                        && in_array($pls2[3]['phase']['3-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-4'])
                        && in_array($pls2[3]['phase']['3-4']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-5'])
                        && in_array($pls2[3]['phase']['3-5']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-' . ASC])
                        && in_array($pls2[3]['phase']['3-' . ASC]['phase_e'], [0, 180])
                    )
                    ||
                    (
                        isset($pls2[3]['phase']['3-' . MC])
                        && in_array($pls2[3]['phase']['3-' . MC]['phase_e'], [0, 180])
                    )
                )
            )
            &&
            (
                (
                    (
                        isset($pls1[1]['phase']['1-0'])
                        && in_array($pls1[1]['phase']['1-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-1'])
                        && in_array($pls1[1]['phase']['1-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-2'])
                        && in_array($pls1[1]['phase']['1-2']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-3'])
                        && in_array($pls1[1]['phase']['1-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-4'])
                        && in_array($pls1[1]['phase']['1-4']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-5'])
                        && in_array($pls1[1]['phase']['1-5']['phase_e'], [0, 60, 120])
                    )
                )
                &&
                (
                    (
                        isset($pls2[1]['phase']['1-0'])
                        && in_array($pls2[1]['phase']['1-0']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-1'])
                        && in_array($pls2[1]['phase']['1-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-2'])
                        && in_array($pls2[1]['phase']['1-2']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-3'])
                        && in_array($pls2[1]['phase']['1-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-4'])
                        && in_array($pls2[1]['phase']['1-4']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[1]['phase']['1-5'])
                        && in_array($pls2[1]['phase']['1-5']['phase_e'], [0, 60, 120])
                    )
                )
            )
            &&
            (
                (
                    isset($pls1[3]['phase']['3-4'])
                    && in_array($pls1[3]['phase']['3-4']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls2[3]['phase']['3-4'])
                    && in_array($pls2[3]['phase']['3-4']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls1[1]['phase']['1-4'])
                    && in_array($pls1[1]['phase']['1-4']['phase_e'], [0, 60, 120])
                )
                ||
                (
                    isset($pls2[1]['phase']['1-4'])
                    && in_array($pls2[1]['phase']['1-4']['phase_e'], [0, 60, 120])
                )
            )
        )
        {
            $if_love = '奉了上天旨意，来做人间仙侣';
        }
        if (
            $attract > 40 && $chat > 40 && $happy > 40 && $passion > 40
            &&
            (
                in_array($pls1_2[0]['in_house_id'], [3, 9])
                || in_array($pls1_2[1]['in_house_id'], [3, 9])
            )
            &&
            (
                in_array($pls2_2[0]['in_house_id'], [3, 9])
                || in_array($pls2_2[1]['in_house_id'], [3, 9])
            )
            &&
            (
                $pls1_2[0]['in_house_id'] == 12
                || $pls1_2[1]['in_house_id'] == 12
                || $pls2_2[0]['in_house_id'] == 12
                || $pls2_2[1]['in_house_id'] == 12
            )
        )
        {
            $if_love = '只谈诗情画意，休说油盐柴米';
        }
        if (
            $attract >= 50 && $chat >= 50 && $passion >= 50 && $benefit >= 50 && $probTobeLover >= 50
            && $val_50more >= 2
        )
        {
            $if_love = '前世已然失约，今生不可错过';
        }
        if ($total > 380 && $chat >= 60 && $benefit >= 60 && $happy >= 60)
        {
            $if_love = '高山流水知音，一生能有几人';
        }


        // 假如恋爱
        $diff_age = abs($this->timestamp1 - $this->timestamp2) / 3600 / 24 / 365;// 两人年龄差
        if ($diff_age < 20 && (($this->sex1 == 1 && $this->sex2 == 2) || ($this->sex1 == 2 && $this->sex2 == 1)))
        {
            $if_love_status = 2;
            if ($passion < 20 && ($chat > 70 || $benefit > 70))
            {
                $if_love = '床上不如床下，缠绵不如说话';
            }
            if (
                (
                    $passion > 60 && $attract < 30 && $chat < 30 && $benefit < 30 && $happy < 30
                )
                ||
                (
                    $foothold_5 > 3
                    && !isset($pls1[0]['phase']['0-3'])
                    && !isset($pls1[1]['phase']['1-3'])
                    && !isset($pls2[0]['phase']['0-3'])
                    && !isset($pls2[1]['phase']['1-3'])
                )
            )
            {
                $if_love = '激情永不熄灭，欲望高于一切';
            }
            if (
                (
                    isset($pls1[0]['phase']['0-1']) && $pls1[0]['phase']['0-1']['phase_e'] == 90
                )
                ||
                (
                    isset($pls2[0]['phase']['0-1']) && $pls2[0]['phase']['0-1']['phase_e'] == 90
                )
                ||
                (
                    isset($pls1[1]['phase']['1-1']) && $pls1[1]['phase']['1-1']['phase_e'] == 90
                )
            )
            {
                $phase_90180_num = 0;
                for ($i = 0; $i < 5; $i++)
                {
                    for ($j = 0; $j < 7; $j++)
                    {
                        if (isset($pls1[$i]['phase'][$i . '-' . $j])
                            && in_array($pls1[$i]['phase'][$i . '-' . $j]['phase_e'], [90, 180]))
                        {
                            $phase_90180_num++;
                        }
                        if (
                            $i != $j
                            && isset($pls2[$i]['phase'][$i . '-' . $j])
                            && in_array($pls2[$i]['phase'][$i . '-' . $j]['phase_e'], [90, 180])
                        )
                        {
                            $phase_90180_num++;
                        }
                    }
                }
                if ($phase_90180_num > 3)
                {
                    $if_love = '不是分分合合，就是相互折磨';
                }
            }
            if (
                $passion > 60 && $probTobeLover < 50
                &&
                (
                    !isset($pls1[0]['phase']['0-3'])
                    || !in_array($pls1[0]['phase']['0-3']['phase_e'], [0, 60, 120])
                    || !isset($pls1[1]['phase']['1-3'])
                    || !in_array($pls1[1]['phase']['1-3']['phase_e'], [0, 60, 120])
                    || !isset($pls2[0]['phase']['0-3'])
                    || !in_array($pls2[0]['phase']['0-3']['phase_e'], [0, 60, 120])
                    || !isset($pls2[1]['phase']['1-3'])
                    || !in_array($pls2[1]['phase']['1-3']['phase_e'], [0, 60, 120])
                )
            )
            {
                $if_love = '别想天长地久，只要曾经拥有';
            }
            $phase_5_num_1 = 0;
            $phase_5_num_90180_1 = 0;
            $phase_5_num_2 = 0;
            $phase_5_num_90180_2 = 0;
            for ($i = 0; $i < 10; $i++)
            {
                if (isset($pls1[3]['phase']['3-' . $i]))
                {
                    $phase_5_num_1++;
                    if (in_array($pls1[3]['phase']['3-' . $i]['phase_e'], [90, 180]))
                    {
                        $phase_5_num_90180_1++;
                    }
                }
                if (isset($pls2[3]['phase']['3-' . $i]))
                {
                    $phase_5_num_2++;
                    if (in_array($pls2[3]['phase']['3-' . $i]['phase_e'], [90, 180]))
                    {
                        $phase_5_num_90180_2++;
                    }
                }
            }
            if (
                $passion > 50
                &&
                (
                    (
                        isset($pls1[0]['phase']['0-1']) && $pls1[0]['phase']['0-1']['phase_e'] != 90
                    )
                    ||
                    (
                        isset($pls1[1]['phase']['1-1']) && $pls1[1]['phase']['1-1']['phase_e'] != 90
                    )
                    ||
                    (
                        isset($pls2[0]['phase']['0-1']) && $pls2[0]['phase']['0-1']['phase_e'] != 90
                    )
                )
                &&
                (
                    (
                        (
                            $phase_5_num_90180_1 > 0 || $phase_5_num_90180_2 > 0
                        )
                        &&
                        (
                            (
                                isset($pls1[3]['or_phase']['3-9'])
                                && $pls1[3]['or_phase']['3-9']['phase_e'] == 90
                            )
                            ||
                            (
                                isset($pls2[3]['or_phase']['3-9'])
                                && $pls2[3]['or_phase']['3-9']['phase_e'] == 90
                            )
                            || $pls1[3]['in_sign_id'] == 8
                            || $pls2[3]['in_sign_id'] == 8
                            ||
                            (
                                isset($pls1[3]['or_phase']['3-4'])
                                && in_array($pls1[3]['or_phase']['3-4']['phase_e'], [90, 180])
                            )
                            ||
                            (
                                isset($pls2[3]['or_phase']['3-4'])
                                && in_array($pls2[3]['or_phase']['3-4']['phase_e'], [90, 180])
                            )
                            ||
                            (
                                isset($pls1[3]['or_phase']['3-1'])
                                && in_array($pls1[3]['or_phase']['3-1']['phase_e'], [90, 180])
                            )
                            ||
                            (
                                isset($pls2[3]['or_phase']['3-1'])
                                && in_array($pls2[3]['or_phase']['3-1']['phase_e'], [90, 180])
                            )
                        )
                    )
                    ||
                    (
                        (
                            $phase_5_num_1 == 1
                            &&
                            (
                                (
                                    isset($pls1[3]['phase']['3-4'])
                                    && in_array($pls1[3]['phase']['3-4']['phase_e'], [90, 180])
                                )
                                ||
                                (
                                    isset($pls1[3]['phase']['3-9'])
                                    && in_array($pls1[3]['phase']['3-9']['phase_e'], [0, 90, 180])
                                )
                            )
                        )
                        ||
                        (
                            $phase_5_num_2 == 1
                            &&
                            (
                                (
                                    isset($pls2[3]['phase']['3-4'])
                                    && in_array($pls2[3]['phase']['3-4']['phase_e'], [90, 180])
                                )
                                ||
                                (
                                    isset($pls2[3]['phase']['3-9'])
                                    && in_array($pls2[3]['phase']['3-9']['phase_e'], [0, 90, 180])
                                )
                            )
                        )
                        ||
                        (
                            $phase_5_num_1 == 2
                            &&
                            (
                                (
                                    isset($pls1[3]['phase']['3-4'])
                                    && in_array($pls1[3]['phase']['3-4']['phase_e'], [90, 180])
                                )
                                &&
                                (
                                    isset($pls1[3]['phase']['3-9'])
                                    && in_array($pls1[3]['phase']['3-9']['phase_e'], [0, 90, 180])
                                )
                            )
                        )
                        ||
                        (
                            $phase_5_num_2 == 2
                            &&
                            (
                                (
                                    isset($pls2[3]['phase']['3-4'])
                                    && in_array($pls2[3]['phase']['3-4']['phase_e'], [90, 180])
                                )
                                &&
                                (
                                    isset($pls2[3]['phase']['3-9'])
                                    && in_array($pls2[3]['phase']['3-9']['phase_e'], [0, 90, 180])
                                )
                            )
                        )
                    )
                )
            )
            {
                $if_love = '恋爱本是酷刑，熬过柳暗花明';
            }

            if (
                $diff_age > 3
                &&
                (
                    (
                        $this->timestamp1 > $this->timestamp2
                        &&
                        (
                            (
                                isset($pls1[1]['phase']['1-6'])
                                && in_array($pls1[1]['phase']['1-6']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls1[1]['phase']['1-0'])
                                && in_array($pls1[1]['phase']['1-0']['phase_e'], [0, 60, 120])
                                && isset($pls1[0]['phase']['0-6'])
                            )
                        )
                    )
                    ||
                    (
                        $this->timestamp1 < $this->timestamp2
                        &&
                        (
                            (
                                isset($pls2[1]['phase']['1-6'])
                                && in_array($pls2[1]['phase']['1-6']['phase_e'], [0, 60, 120])
                            )
                            ||
                            (
                                isset($pls2[1]['phase']['1-0'])
                                && in_array($pls2[1]['phase']['1-0']['phase_e'], [0, 60, 120])
                                && isset($pls2[0]['phase']['0-6'])
                            )
                        )
                    )
                )
                &&
                (
                    (
                        isset($pls1[2]['phase']['2-1'])
                        && in_array($pls1[2]['phase']['2-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-3'])
                        && in_array($pls1[2]['phase']['2-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls1[2]['phase']['2-5'])
                        && in_array($pls1[2]['phase']['2-5']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-1'])
                        && in_array($pls2[2]['phase']['2-1']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-3'])
                        && in_array($pls2[2]['phase']['2-3']['phase_e'], [0, 60, 120])
                    )
                    ||
                    (
                        isset($pls2[2]['phase']['2-5'])
                        && in_array($pls2[2]['phase']['2-5']['phase_e'], [0, 60, 120])
                    )
                    || in_array($pls1_2[1]['in_house_id'], [6, 10])
                    || in_array($pls2_2[1]['in_house_id'], [6, 10])
                )
            )
            {
                $if_love = '学生遇到师长，情爱出自景仰';
            }
            $phase_01_90180_num = 0;
            for ($i = 0; $j < 7; $j++)
            {
                if ($j == 5) continue;
                if (isset($pls1[0]['phase']['0-' . $i])
                    && in_array($pls1[0]['phase']['0-' . $i]['phase_e'], [90, 180]))
                {
                    $phase_01_90180_num++;
                }
                if (isset($pls1[1]['phase']['1-' . $i])
                    && in_array($pls1[1]['phase']['1-' . $i]['phase_e'], [90, 180]))
                {
                    $phase_01_90180_num++;
                }
                if (isset($pls2[0]['phase']['0-' . $i])
                    && in_array($pls2[0]['phase']['0-' . $i]['phase_e'], [90, 180]))
                {
                    $phase_01_90180_num++;
                }
                if (isset($pls2[1]['phase']['1-' . $i])
                    && in_array($pls2[1]['phase']['1-' . $i]['phase_e'], [90, 180]))
                {
                    $phase_01_90180_num++;
                }
            }
            if (
                ($attract + $passion) > 120
                && $phase_01_90180_num > 3
                &&
                (
                    isset($pls1[0]['phase']['0-8'])
                    || isset($pls2[0]['phase']['0-8'])
                )
                &&
                (
                    isset($pls1[1]['phase']['1-8'])
                    || isset($pls2[1]['phase']['1-8'])
                )
                &&
                (
                    $pls1[0]['in_sign_id'] == 12
                    || $pls1[1]['in_sign_id'] == 12
                    || $pls1[3]['in_sign_id'] == 12
                    || $pls2[0]['in_sign_id'] == 12
                    || $pls2[1]['in_sign_id'] == 12
                    || $pls2[3]['in_sign_id'] == 12
                    ||
                    (
                        isset($pls1[0]['or_phase']['0-8'])
                        && in_array($pls1[0]['or_phase']['0-8']['phase_e'], [0, 90, 180])
                    )
                    ||
                    (
                        isset($pls1[1]['or_phase']['1-8'])
                        && in_array($pls1[1]['or_phase']['1-8']['phase_e'], [0, 90, 180])
                    )
                    ||
                    (
                        isset($pls2[0]['or_phase']['0-8'])
                        && in_array($pls2[0]['or_phase']['0-8']['phase_e'], [0, 90, 180])
                    )
                    ||
                    (
                        isset($pls2[1]['or_phase']['1-8'])
                        && in_array($pls2[1]['or_phase']['1-8']['phase_e'], [0, 90, 180])
                    )
                    ||
                    (
                        isset($pls1[3]['or_phase']['3-8']) && isset($pls1[4]['or_phase']['4-8'])
                    )
                    ||
                    (
                        isset($pls2[3]['or_phase']['3-8']) && isset($pls2[4]['or_phase']['4-8'])
                    )
                )
            )
            {
                $if_love = '爱到迷失自我，好似飞蛾扑火';
            }

            // 尽管相爱相知，最怕两地相思
            // 亲密或激情>60且双方都满足以下条件之一
            // 月亮在水瓶座或月天刑冲合
            // 金星在水瓶座或金天刑冲合
            // 天王独坐5宫或7宫
            $house5_pl_num_1 = 0;
            $house7_pl_num_1 = 0;
            $house5_pl_num_2 = 0;
            $house7_pl_num_2 = 0;
            for ($i = 0; $i < 10; $i++)
            {
                if ($pls1[$i]['in_house_id'] == 5) $house5_pl_num_1++;
                if ($pls1[$i]['in_house_id'] == 7) $house7_pl_num_1++;
                if ($pls2[$i]['in_house_id'] == 5) $house5_pl_num_2++;
                if ($pls2[$i]['in_house_id'] == 7) $house7_pl_num_2++;
            }
//        p($pls1);
//        p($pls1[1]['in_sign_id']);
//        p($pls1[3]['or_phase']);
//
//        p($pls2[1]['in_sign_id']);
//        p($pls2[3]['or_phase']);
//        exit;
            if ($benefit > 60 || $passion > 60)
            {
                if (
                    (
                        $pls1[1]['in_sign_id'] == 11
                        ||
                        (isset($pls1[1]['or_phase']['1-7']) && in_array($pls1[1]['or_phase']['1-7']['phase_e'], [0, 90, 180]))
                        ||
                        $pls1[3]['in_sign_id'] == 11
                        ||
                        (isset($pls1[3]['or_phase']['3-7']) && in_array($pls1[3]['or_phase']['3-7']['phase_e'], [0, 90, 180]))
                        ||
                        ($house5_pl_num_1 == 1 && $pls1[7]['in_house_id'] == 5)
                        ||
                        ($house7_pl_num_1 == 1 && $pls1[7]['in_house_id'] == 7)
                    )
                    &&
                    (
                        $pls2[1]['in_sign_id'] == 11
                        ||
                        (isset($pls2[1]['or_phase']['1-7']) && in_array($pls2[1]['or_phase']['1-7']['phase_e'], [0, 90, 180]))
                        ||
                        $pls2[3]['in_sign_id'] == 11
                        ||
                        (isset($pls2[3]['or_phase']['3-7']) && in_array($pls2[3]['or_phase']['3-7']['phase_e'], [0, 90, 180]))
                        ||
                        ($house5_pl_num_2 == 1 && $pls2[7]['in_house_id'] == 5)
                        ||
                        ($house7_pl_num_2 == 1 && $pls2[7]['in_house_id'] == 7)
                    )
                )
                {
                    $if_love = '尽管相爱相知，最怕两地相思';
                }
            }
            // 冲突高于50%，或所有指数均低于30$attract = 0,$chat = 0,$passion = 0,$benefit = 0,$happy = 0,$probTobeLover = 0
            if ($harmoniousAndConflict[1] > 50
                ||
                ($attract < 30 && $chat < 30 && $passion < 30 && $benefit < 30 && $happy < 30 && $probTobeLover < 30)
            )
            {
                $if_love = '喜欢的人没缘，强扭的瓜不甜';
            }


            // 立足点“性情相似、投缘，有默契，容易相互理解”成立，且合盘无金月、金火、金日的合拱六分且无金星合轴
            if (
                $foothold_8 > 3
                &&
                (
                    (!isset($pls1_2[3]['phase']['3-0']) || !in_array($pls1_2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls1_2[3]['phase']['3-1']) || !in_array($pls1_2[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls1_2[3]['phase']['3-4']) || !in_array($pls1_2[3]['phase']['3-4']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls1_2[3]['phase']['3-' . ASC]) || !in_array($pls1_2[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                    &&
                    (!isset($pls1_2[3]['phase']['3-' . MC]) || !in_array($pls1_2[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                    &&
                    (!isset($pls2_2[3]['phase']['3-0']) || !in_array($pls2_2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls2_2[3]['phase']['3-1']) || !in_array($pls2_2[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls2_2[3]['phase']['3-4']) || !in_array($pls2_2[3]['phase']['3-4']['phase_e'], [0, 60, 120]))
                    &&
                    (!isset($pls2_2[3]['phase']['3-' . ASC]) || !in_array($pls2_2[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                    &&
                    (!isset($pls2_2[3]['phase']['3-' . MC]) || !in_array($pls2_2[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                )
            )
            {
                $if_love = '相知实在简单，相爱有点困难';
            }
            // 双方金星均与对方太阳或金星合拱六分，但火星未与对方日月金火成非刑相
            if (
                (
                    (isset($pls1[3]['phase']['3-0']) && in_array($pls1[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                    ||
                    (isset($pls1[3]['phase']['3-3']) && in_array($pls1[3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                )
                &&
                (
                (isset($pls2[3]['phase']['3-0']) && in_array($pls2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                )
                &&
                (
                    (!isset($pls1[4]['phase']['4-0']) || $pls1[4]['phase']['4-0']['phase_e'] == 90)
                    &&
                    (!isset($pls1[4]['phase']['4-1']) || $pls1[4]['phase']['4-1']['phase_e'] == 90)
                    &&
                    (!isset($pls1[4]['phase']['4-3']) || $pls1[4]['phase']['4-3']['phase_e'] == 90)
                    &&
                    (!isset($pls1[4]['phase']['4-4']) || $pls1[4]['phase']['4-4']['phase_e'] == 90)
                )
                &&
                (
                    (!isset($pls2[4]['phase']['4-0']) || $pls2[4]['phase']['4-0']['phase_e'] == 90)
                    &&
                    (!isset($pls2[4]['phase']['4-1']) || $pls2[4]['phase']['4-1']['phase_e'] == 90)
                    &&
                    (!isset($pls2[4]['phase']['4-3']) || $pls2[4]['phase']['4-3']['phase_e'] == 90)
                )
            )
            {
                $if_love = '相处其乐融融，就怕不是爱情';
            }
            // 吸引、激情均低于20，亲密不高于70
            if ($attract < 20 && $passion < 20 && $benefit <= 70)
            {
                $if_love = '一时冲动牵手，最终做回朋友';
            }
            // 有玩伴关系，亲密低于30，缘分低于50
            $is_player = false;
            if (!empty($relation)) foreach ($relation as $rl) if ($rl['name_en'] == 'player') $is_player = true;
            if ($is_player && $benefit < 30 && $probTobeLover < 50)
            {
                $if_love = '说是情人知己，不过玩玩而已';
            }
        }


        if ($if_love === '')
        {
            if ($total > 300) $if_love = '难得有情知己，定然许多欢喜';
            elseif ($total > 220) $if_love = '自信前缘深厚，不妨执子之手';
            elseif ($total > 140) $if_love = '若要耳鬓厮磨，总有争执不合';
            else $if_love = '前世冤家聚首，什么情况都有';
        }

//        $score1_test =  [
//            '成长'=>$score1['grow'],
//            '物质'=>$score1['substance'],
//            '关爱'=>$score1['care'],
//            '激励'=>$score1['motivate'],
//            '安全'=>$score1['relieved'],
//            '幸运'=>$score1['luck']
//        ];
//        $score2_test =  [
//            '成长'=>$score2['grow'],
//            '物质'=>$score2['substance'],
//            '关爱'=>$score2['care'],
//            '激励'=>$score2['motivate'],
//            '安全'=>$score2['relieved'],
//            '幸运'=>$score2['luck']
//        ];
//        p($ret);
//        p($ret2);
//        p($score1_test);
//        p($score2_test);
//        p($score1);
//        p($score2);
//        p($if_love);
//        exit;
        return [
            'foothold' => $ret, 'conflict' => $ret2,
            'score1' => $score1, 'score2' => $score2, 'if_love' => $if_love, 'if_love_status' => $if_love_status
        ];
    }

    /**
     * 吸引指数
     * 基数=金星正指数-金星负指数
     * 1、若存在日月、金火非刑相，每有一组则+50*相位系数*容许度系数（相位系数：合1，拱0.85，六分0.75，冲0.9）；
     * 2、若一方火星刑对方金星，其金星也刑对方火星，或其金星与对分月亮或太阳合拱六分，此时若其金星无刑相位且不与土星成相，+36；
     * 3、若一方太阳或月亮进入对方的5或7宫，每有一个+15
     * ##########4、一方金星若与对方土星刑冲，-35
     * 4、若一方太阳或月亮与对方上升或下降相合，每有一个+20
     * 5、若一方太阳或月亮与对方天顶或天底相合，每有一个+15
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     * @return int
     */
    protected function getTheAttractScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);

        $ret += ($coef1['obverse'][3] + $coef2['obverse'][3]) - ($coef1['versa'][3] + $coef2['versa'][3]);
//        if($debug) echo "金星正指数({$coef1['obverse'][3]} + {$coef2['obverse'][3]}) -金星负指数({$coef1['versa'][3]} + {$coef2['versa'][3]})\n";

        $planets1 = $data1['details2']['planets'];// 外圈数据B
        $planets2 = $data2['details2']['planets'];// 外圈数据A
        $phase_e = $phase_o = 0;
        // 若存在日月、金火非刑相，每有一组则+50*相位系数*容许度系数（相位系数：合1，拱0.85，六分0.75，冲0.9）；
        // 日月
        if (isset($planets1[0]['phase']['0-1']) && $planets1[0]['phase']['0-1']['phase_e'] != 90)
        {
            $_e = $planets1[0]['phase']['0-1']['phase_e'];
            $_orb = $planets1[0]['phase']['0-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 50 * $phase_e * $phase_o;
        }
        // 月日
        if (isset($planets1[1]['phase']['1-0']) && $planets1[1]['phase']['1-0']['phase_e'] != 90)
        {
            $_e = $planets1[1]['phase']['1-0']['phase_e'];
            $_orb = $planets1[1]['phase']['1-0']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 50 * $phase_e * $phase_o;
        }
//        p($planets1[0]);
//        p($planets2[0]);
//        exit;
        // 金火
        if (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] != 90)
        {
            $_e = $planets1[3]['phase']['3-4']['phase_e'];
            $_orb = $planets1[3]['phase']['3-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 50 * $phase_e * $phase_o;
        }
        // 火金
        if (isset($planets2[3]['phase']['3-4']) && $planets2[3]['phase']['3-4']['phase_e'] != 90)
        {
            $_e = $planets2[3]['phase']['3-4']['phase_e'];
            $_orb = $planets2[3]['phase']['3-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 50 * $phase_e * $phase_o;
        }
        // 若一方火星刑对方金星，其金星也刑对方火星，或其金星与月亮或太阳合拱六分，此时若其金星无刑相位且不与土星成相，+36；
        if (isset($planets1[4]['phase']['4-3']) && $planets1[4]['phase']['4-3']['phase_e'] == 90
            && (
                (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] == 90)
                || (isset($planets1[3]['phase']['3-0']) && in_array($planets1[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                || (isset($planets1[3]['phase']['3-1']) && in_array($planets1[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
            ) && !isset($planets1[3]['phase']['3-6'])
        )
        {
            $venu_phase90_num = 0;
            foreach ($planets1[3]['phase'] as $ph)
            {
                if ($ph['phase_e'] == 90) $venu_phase90_num++;
            }
            if ($venu_phase90_num == 0) $ret += 36;
        }
        if (isset($planets2[4]['phase']['4-3']) && $planets2[4]['phase']['4-3']['phase_e'] == 90
            && (
                (isset($planets2[3]['phase']['3-4']) && $planets2[3]['phase']['3-4']['phase_e'] == 90)
                || (isset($planets2[3]['phase']['3-0']) && in_array($planets2[3]['phase']['3-0']['phase_e'], [0, 60, 120]))
                || (isset($planets2[3]['phase']['3-1']) && in_array($planets2[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
            ) && !isset($planets2[3]['phase']['3-6'])
        )
        {
            $venu_phase90_num = 0;
            foreach ($planets2[3]['phase'] as $ph)
            {
                if ($ph['phase_e'] == 90) $venu_phase90_num++;
            }
            if ($venu_phase90_num == 0) $ret += 36;
        }
        // 若一方太阳或月亮进入对方的5或7宫，每有一个+20
        if (in_array($planets1[0]['in_house_id'], [5, 7]))
        {
            $ret += 20;
        }
        if (in_array($planets1[1]['in_house_id'], [5, 7]))
        {
            $ret += 20;
        }
        if (in_array($planets2[0]['in_house_id'], [5, 7]))
        {
            $ret += 20;
        }
        if (in_array($planets2[1]['in_house_id'], [5, 7]))
        {
            $ret += 20;
        }
        // 若一方金火进入对方的5或7宫，每有一个+15
        if (in_array($planets1[3]['in_house_id'], [5, 7]))
        {
            $ret += 15;
        }
        if (in_array($planets1[4]['in_house_id'], [5, 7]))
        {
            $ret += 15;
        }
        if (in_array($planets2[3]['in_house_id'], [5, 7]))
        {
            $ret += 15;
        }
        if (in_array($planets2[4]['in_house_id'], [5, 7]))
        {
            $ret += 15;
        }
        // 一方金星若与对方土星刑冲，-35
        if (isset($planets1[3]['phase']['3-6']) && in_array($planets1[3]['phase']['3-6']['phase_e'], [90, 180]))
        {
            $ret -= 35;
        }
        if (isset($planets1[6]['phase']['6-3']) && in_array($planets1[6]['phase']['6-3']['phase_e'], [90, 180]))
        {
            $ret -= 35;
        }
        // 月亮与对方土星刑冲-40  去掉  20180119 by gks

        // 若存在日月金火之间的冲相位，每个+8
        for ($i = 0; $i < 5; $i++)
        {
            if ($i == 2) continue;
            for ($j = 0; $j < 5; $j++)
            {
                if ($j == 2 || $j < $i) continue;

                $tk = $i . '-' . $j;

                if (isset($planets1[$i]['phase'][$tk]) && $planets1[$i]['phase'][$tk]['phase_e'] == 180)
                {
                    $ret += 8;
                }
                if (isset($planets2[$i]['phase'][$tk]) && $planets2[$i]['phase'][$tk]['phase_e'] == 180)
                {
                    $ret += 8;
                }
            }
        }
        // 若有一方日月金火之一与对方日月金水火木两颗以上成非刑相，+6*x（x为相位个数，多个类似情况只计分一次,按相位多的记分）
        $t_o = [];
        for ($i = 0; $i < 5; $i++)
        {
            if ($i == 2) continue;
            $x1 = 0;
            $x2 = 0;
            for ($j = 0; $j < 6; $j++)
            {
                $tk = $i . '-' . $j;
                if (isset($planets1[$i]['phase'][$tk]) && $planets1[$i]['phase'][$tk]['phase_e'] != 90)
                {
                    $x1++;
                }
                if (isset($planets2[$i]['phase'][$tk]) && $planets2[$i]['phase'][$tk]['phase_e'] != 90)
                {
                    $x2++;
                }
            }
            if ($x1 > 2) $t_o[] = $x1;
            if ($x2 > 2) $t_o[] = $x2;
        }
        if (count($t_o) > 0)
        {
            $ret += (max($t_o) * 6);
        }

        // 若一方太阳或月亮与对方上升或下降相合，每有一个+20
        // 日升
        if (isset($planets1[0]['phase']['0-' . ASC]) && in_array($planets1[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
        {
            $ret += 20;
        }
        // 升日
        if (isset($planets1[ASC]['phase'][ASC . '-0']) && in_array($planets1[ASC]['phase'][ASC . '-0']['phase_e'], [0, 180]))
        {
            $ret += 20;
        }
        // 月升
        if (isset($planets1[1]['phase']['1-' . ASC]) && in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
        {
            $ret += 20;
        }
        // 升月
        if (isset($planets1[ASC]['phase'][ASC . '-1']) && in_array($planets1[ASC]['phase'][ASC . '-1']['phase_e'], [0, 180]))
        {
            $ret += 20;
        }
        // 若一方太阳或月亮与对方天顶或天底相合，每有一个+15
        // 日顶
        if (isset($planets1[0]['phase']['0-' . MC]) && in_array($planets1[0]['phase']['0-' . MC]['phase_e'], [0, 180]))
        {
            $ret += 15;
        }
        // 顶日
        if (isset($planets1[MC]['phase'][MC . '-0']) && in_array($planets1[MC]['phase'][MC . '-0']['phase_e'], [0, 180]))
        {
            $ret += 15;
        }
        // 月顶
        if (isset($planets1[1]['phase']['1-' . MC]) && in_array($planets1[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
        {
            $ret += 15;
        }
        // 顶月
        if (isset($planets1[MC]['phase'][MC . '-1']) && in_array($planets1[MC]['phase'][MC . '-1']['phase_e'], [0, 180]))
        {
            $ret += 15;
        }

        return $ret;
    }

    /**
     * 前缘指数
     * 基数=北交点正指数*2+海王星正指数+冥王星正指数
     * @param array $data1
     * @param array $data2
     * @param int $x
     * @param bool $debug
     * @return int
     */
    protected function getTheFateScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);

        $ret += ($coef1['obverse'][12] + $coef2['obverse'][12]) * 2
            + $coef1['obverse'][8] + $coef2['obverse'][8]
            + $coef1['obverse'][9] + $coef2['obverse'][9];
        return $ret;
    }

    /**
     * 沟通指数
     * 基数=月亮正指数+水星正指数-水星负指数-月亮负指数
     * #######若双方水星有且只有与对方月、水、日、金、木、上升、中天的合拱六分相，+35；######
     * #######若双方月亮有且只有与对方月、水、日、金、木、上升、中天的合拱六分相，+50；######
     * 若双方水星都有与对方月、水、日、金、木的合拱六分相，且无刑冲相位，也无火、土相位，则加35
     * 若双方月亮都有与对方月、水、日、金、木的合拱六分相，且无刑冲相位，也无火、土相位，则加50
     * @param array $data1
     * @param array $data2
     * @param int $x
     * @param bool $debug
     * @return int
     */
    protected function getTheChatScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);

//        $ret += $coef1['obverse'][1] + $coef2['obverse'][1]
//            + $coef1['obverse'][2] + $coef2['obverse'][2]
//            - $coef1['versa'][1] - $coef2['versa'][1] - $coef1['versa'][2] - $coef2['versa'][2];
//        $ret += ($coef1['obverse'][2] + $coef2['obverse'][2]) * 1.5 + ($coef1['obverse'][1] + $coef2['obverse'][1]) * 0.5;
        $housePower = $this->getTheHousePower($data1, $data2);// 宫位能量  0 正 | 1 负
//        沟通=30+水正-水负+9正-9负+3正-3负
        $ret += 30 + ($coef1['obverse'][2] + $coef2['obverse'][2]) - $coef1['versa'][2] - $coef2['versa'][2]
            + $housePower[0][9] - $housePower[1][9] + $housePower[0][3] - $housePower[1][3];

        $planets1 = $data1['details2']['planets'];
        $planets2 = $data2['details2']['planets'];
        // 双方月亮无与火星土星天王海王冥王的合刑冲，且无与日月金水的刑相位，且至少有一个与日月金木的合拱六分相
        if (
            (!isset($planets1[1]['phase']['1-4']) || !in_array($planets1[1]['phase']['1-4']['phase_e'], [0, 90, 180]))
            && (!isset($planets1[1]['phase']['1-6']) || !in_array($planets1[1]['phase']['1-6']['phase_e'], [0, 90, 180]))
            && (!isset($planets1[1]['phase']['1-7']) || !in_array($planets1[1]['phase']['1-7']['phase_e'], [0, 90, 180]))
            && (!isset($planets1[1]['phase']['1-8']) || !in_array($planets1[1]['phase']['1-8']['phase_e'], [0, 90, 180]))
            && (!isset($planets1[1]['phase']['1-9']) || !in_array($planets1[1]['phase']['1-9']['phase_e'], [0, 90, 180]))
            && (!isset($planets2[1]['phase']['1-4']) || !in_array($planets2[1]['phase']['1-4']['phase_e'], [0, 90, 180]))
            && (!isset($planets2[1]['phase']['1-6']) || !in_array($planets2[1]['phase']['1-6']['phase_e'], [0, 90, 180]))
            && (!isset($planets2[1]['phase']['1-7']) || !in_array($planets2[1]['phase']['1-7']['phase_e'], [0, 90, 180]))
            && (!isset($planets2[1]['phase']['1-8']) || !in_array($planets2[1]['phase']['1-8']['phase_e'], [0, 90, 180]))
            && (!isset($planets2[1]['phase']['1-9']) || !in_array($planets2[1]['phase']['1-9']['phase_e'], [0, 90, 180]))
            && (!isset($planets1[1]['phase']['1-0']) || $planets1[1]['phase']['1-0']['phase_e'] != 90)
            && (!isset($planets1[1]['phase']['1-1']) || $planets1[1]['phase']['1-1']['phase_e'] != 90)
            && (!isset($planets1[1]['phase']['1-2']) || $planets1[1]['phase']['1-2']['phase_e'] != 90)
            && (!isset($planets1[1]['phase']['1-3']) || $planets1[1]['phase']['1-3']['phase_e'] != 90)
            && (!isset($planets2[1]['phase']['1-0']) || $planets2[1]['phase']['1-0']['phase_e'] != 90)
            && (!isset($planets2[1]['phase']['1-2']) || $planets2[1]['phase']['1-2']['phase_e'] != 90)
            && (!isset($planets2[1]['phase']['1-3']) || $planets2[1]['phase']['1-3']['phase_e'] != 90)
            &&
            (
                (isset($planets1[1]['phase']['1-0']) && in_array($planets1[1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                || (isset($planets1[1]['phase']['1-1']) && in_array($planets1[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                || (isset($planets1[1]['phase']['1-3']) && in_array($planets1[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                || (isset($planets1[1]['phase']['1-5']) && in_array($planets1[1]['phase']['1-5']['phase_e'], [0, 60, 120]))
            )
            &&
            (
                (isset($planets2[1]['phase']['1-0']) && in_array($planets2[1]['phase']['1-0']['phase_e'], [0, 60, 120]))
                || (isset($planets2[1]['phase']['1-1']) && in_array($planets2[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                || (isset($planets2[1]['phase']['1-3']) && in_array($planets2[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                || (isset($planets2[1]['phase']['1-5']) && in_array($planets2[1]['phase']['1-5']['phase_e'], [0, 60, 120]))
            )
        )
        {
            $ret += 50;
        }

        $merc1_phase_b = [0, 0];
        if (!empty($planets1[2]['phase']))
        {
            foreach ($planets1[2]['phase'] as $merc1_phase)
            {
                if ($merc1_phase['id'] > 9 || $merc1_phase['id'] < ASC) continue;
                if (in_array($merc1_phase['phase_e'], [0, 60, 120]))
                {

                    if (in_array($merc1_phase['id'], [0, 1, 2, 3, 5]))
                    {
                        $merc1_phase_b[0]++;
                    } else
                    {
                        $merc1_phase_b[1]++;
                    }
                }
                if (in_array($merc1_phase['phase_e'], [90, 180]))
                {
                    $merc1_phase_b[1]++;
                }
            }
        }
        $merc2_phase_b = [0, 0];
        if (!empty($planets2[2]['phase']))
        {
            foreach ($planets2[2]['phase'] as $merc2_phase)
            {
                if ($merc2_phase['id'] > 9 || $merc2_phase['id'] < ASC) continue;
                if (in_array($merc2_phase['phase_e'], [0, 60, 120]))
                {

                    if (in_array($merc2_phase['id'], [0, 1, 2, 3, 5]))
                    {
                        $merc2_phase_b[0]++;
                    } else
                    {
                        $merc2_phase_b[1]++;
                    }
                }
                if (in_array($merc2_phase['phase_e'], [90, 180]))
                {
                    $merc2_phase_b[1]++;
                }
            }
        }
        if ($merc1_phase_b[0] && !$merc1_phase_b[1] && $merc2_phase_b[0] && !$merc2_phase_b[1])
        {
            $ret += 35;
        }
        // 若双方水星均与对方木星或月亮成合拱六分相，+25
        if (
            (
                (isset($planets1[2]['phase']['2-1']) && in_array($planets1[2]['phase']['2-1']['phase_e'], [0, 60, 120]))
                || (isset($planets1[2]['phase']['2-5']) && in_array($planets1[2]['phase']['2-5']['phase_e'], [0, 60, 120]))
            )
            &&
            (
                (isset($planets2[2]['phase']['2-1']) && in_array($planets2[2]['phase']['2-1']['phase_e'], [0, 60, 120]))
                || (isset($planets2[2]['phase']['2-5']) && in_array($planets2[2]['phase']['2-5']['phase_e'], [0, 60, 120]))
            )
        )
        {
            $ret += 25;
        }

//        若双方水星互相刑-15；
        if (isset($planets1[2]['phase']['2-2']) && $planets1[2]['phase']['2-2']['phase_e'] == 90)
        {
            $ret -= 15;
        }
//        若一方水星与另一方土星刑冲-15；
        if (
            (isset($planets1[2]['phase']['2-6']) && in_array($planets1[2]['phase']['2-6']['phase_e'], [90, 180]))
            || (isset($planets2[2]['phase']['2-6']) && in_array($planets2[2]['phase']['2-6']['phase_e'], [90, 180]))
        )
        {
            $ret -= 15;
        }
//        若一方水星与另一方月亮刑-18；
        if (
            (isset($planets1[2]['phase']['2-1']) && $planets1[2]['phase']['2-1']['phase_e'] == 90)
            || (isset($planets2[2]['phase']['2-1']) && $planets2[2]['phase']['2-1']['phase_e'] == 90)
        )
        {
            $ret -= 18;
        }
//        若一方水星与另一方月亮对冲-12；
        if (
            (isset($planets1[2]['phase']['2-1']) && $planets1[2]['phase']['2-1']['phase_e'] == 180)
            || (isset($planets2[2]['phase']['2-1']) && $planets2[2]['phase']['2-1']['phase_e'] == 180)
        )
        {
            $ret -= 12;
        }
//        若一方水星与另一方火星刑冲-12；
        if (
            (isset($planets1[2]['phase']['2-4']) && in_array($planets1[2]['phase']['2-4']['phase_e'], [90, 180]))
            || (isset($planets2[2]['phase']['2-4']) && in_array($planets2[2]['phase']['2-4']['phase_e'], [90, 180]))
        )
        {
            $ret -= 12;
        }
//        若一方水星与另一方太阳刑-13；
        if (
            (isset($planets1[2]['phase']['2-0']) && $planets1[2]['phase']['2-0']['phase_e'] == 90)
            || (isset($planets2[2]['phase']['2-0']) && $planets2[2]['phase']['2-0']['phase_e'] == 90)
        )
        {
            $ret -= 13;
        }
//        若一方水星与另一方太阳对冲-9；
        if (
            (isset($planets1[2]['phase']['2-0']) && $planets1[2]['phase']['2-0']['phase_e'] == 180)
            || (isset($planets2[2]['phase']['2-0']) && $planets2[2]['phase']['2-0']['phase_e'] == 180)
        )
        {
            $ret -= 9;
        }
//        若一方土星落对方3宫-10，若此时土星刑冲对方日月水，每个-10
        if (
            $planets1[6]['in_house_id'] == 3 || $planets2[6]['in_house_id'] == 3
        )
        {
            $ret -= 10;
            if ($planets1[6]['in_house_id'] == 3)
            {
                if (isset($planets1[6]['phase']['6-0']) && in_array($planets1[6]['phase']['6-0']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
                if (isset($planets1[6]['phase']['6-1']) && in_array($planets1[6]['phase']['6-1']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
                if (isset($planets1[6]['phase']['6-2']) && in_array($planets1[6]['phase']['6-2']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
            }
            if ($planets2[6]['in_house_id'] == 3)
            {
                if (isset($planets2[6]['phase']['6-0']) && in_array($planets2[6]['phase']['6-0']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
                if (isset($planets2[6]['phase']['6-1']) && in_array($planets2[6]['phase']['6-1']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
                if (isset($planets2[6]['phase']['6-2']) && in_array($planets2[6]['phase']['6-2']['phase_e'], [90, 180]))
                {
                    $ret -= 10;
                }
            }
        }


        return $ret;
    }

    /**
     * 激情指数
     * 基数=火星正指数
     * 若存在火金、火火非刑相，每个+40*相位系数*容许系数；
     * 若存在日火、月火非刑相，每个+20*相位系数*容许系数；
     * 若存在火星与土星的合刑冲相，每个-30*相位系数*容许系数；
     * @param array $data1
     * @param array $data2
     * @param int $x
     * @param bool $debug
     * @return int
     */
    protected function getThePassionScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);

        $planets1 = $data1['details2']['planets'];
        $planets2 = $data2['details2']['planets'];

        $ret += $coef1['obverse'][4] + $coef2['obverse'][4];
        $phase_e = 0;
        // 若存在火金、火火非刑相，每个+40*相位系数*容许系数；
        // 火金
        if (isset($planets1[4]['phase']['4-3']) && $planets1[4]['phase']['4-3']['phase_e'] != 90)
        {
            $_e = $planets1[4]['phase']['4-3']['phase_e'];
            $_orb = $planets1[4]['phase']['4-3']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 40 * $phase_e * $phase_o;
            // （若双方为一男一女，成相火星属于男方，则额外+20）
            if ($this->sex1 == 2 && $this->sex2 == 1)
            {
                $ret += 20;
            }
        }
        // 金火
        if (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] != 90)
        {
            $_e = $planets1[3]['phase']['3-4']['phase_e'];
            $_orb = $planets1[3]['phase']['3-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 40 * $phase_e * $phase_o;
            // （若双方为一男一女，成相火星属于男方，则额外+20）
            if ($this->sex1 == 1 && $this->sex2 == 2)
            {
                $ret += 20;
            }
        }
        // 火火
        if (isset($planets1[4]['phase']['4-4']) && $planets1[4]['phase']['4-4']['phase_e'] != 90)
        {
            $_e = $planets1[4]['phase']['4-4']['phase_e'];
            $_orb = $planets1[4]['phase']['4-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 40 * $phase_e * $phase_o;
            // （若双方为一男一女，成相火星属于男方，则额外+20）
            if (($this->sex1 == 1 && $this->sex2 == 2) || ($this->sex2 == 1 && $this->sex2 == 1))
            {
                $ret += 20;
            }
        }
        // 若存在日火、月火非刑相，每个+20*相位系数*容许系数；
        // 日火
        if (isset($planets1[0]['phase']['0-4']) && $planets1[0]['phase']['0-4']['phase_e'] != 90)
        {
            $_e = $planets1[0]['phase']['0-4']['phase_e'];
            $_orb = $planets1[0]['phase']['0-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 20 * $phase_e * $phase_o;
        }
        // 火日
        if (isset($planets1[4]['phase']['4-0']) && $planets1[4]['phase']['4-0']['phase_e'] != 90)
        {
            $_e = $planets1[4]['phase']['4-0']['phase_e'];
            $_orb = $planets1[4]['phase']['4-0']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 20 * $phase_e * $phase_o;
        }
        // 月火
        if (isset($planets1[1]['phase']['1-4']) && $planets1[1]['phase']['1-4']['phase_e'] != 90)
        {
            $_e = $planets1[1]['phase']['1-4']['phase_e'];
            $_orb = $planets1[1]['phase']['1-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 20 * $phase_e * $phase_o;
        }
        // 火月
        if (isset($planets1[4]['phase']['4-1']) && $planets1[4]['phase']['4-1']['phase_e'] != 90)
        {
            $_e = $planets1[4]['phase']['4-1']['phase_e'];
            $_orb = $planets1[4]['phase']['4-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret += 20 * $phase_e * $phase_o;
        }
        // 若存在火星与土星的合刑冲相，每个-30*相位系数*容许系数；
        // 火土
        if (isset($planets1[4]['phase']['4-6']) && in_array($planets1[4]['phase']['4-6']['phase_e'], [0, 90, 180]))
        {
            $_e = $planets1[4]['phase']['4-6']['phase_e'];
            $_orb = $planets1[4]['phase']['4-6']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret -= 30 * $phase_e * $phase_o;
        }
        // 土火
        if (isset($planets1[6]['phase']['6-4']) && in_array($planets1[6]['phase']['6-4']['phase_e'], [0, 90, 180]))
        {
            $_e = $planets1[6]['phase']['6-4']['phase_e'];
            $_orb = $planets1[6]['phase']['6-4']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 90) $phase_e = 0.8;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            if ($phase_e) $ret -= 30 * $phase_e * $phase_o;
        }
        // 若一方火星进入对方1/5/7宫，+10；若双方均如此，再加20
        if (in_array($planets1[4]['in_house_id'], [1, 5, 7]))
        {
            $ret += 10;
        }
        if (in_array($planets2[4]['in_house_id'], [1, 5, 7]))
        {
            $ret += 10;
        }
        if (in_array($planets1[4]['in_house_id'], [1, 5, 7]) && in_array($planets2[4]['in_house_id'], [1, 5, 7]))
        {
            $ret += 20;
        }

        return $ret;
    }

    /**
     * 长久指数
     * 基数=Asc+Mc的正指数合 + 太阳的正指数合 +月亮的正指数合+土星的正指数合-月亮的负指数合-太阳的负指数合-ASC的负指数合-MC的负指数合-天王星的负指数合；
     * 若天王星与轴点合相，每多一组*0.8；
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     * @return float
     */
    protected function getThePermanentlyScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);

        $ret += $coef1['obverse'][ASC] + $coef2['obverse'][ASC] + $coef1['obverse'][MC] + $coef2['obverse'][MC]
            + $coef1['obverse'][0] + $coef2['obverse'][0] + $coef1['obverse'][1] + $coef2['obverse'][1]
            + $coef1['obverse'][6] + $coef2['obverse'][6]
            - $coef1['versa'][0] - $coef2['versa'][0] - $coef1['versa'][1] - $coef2['versa'][1]
            - $coef1['versa'][ASC] - $coef2['versa'][ASC] - $coef1['versa'][MC] - $coef2['versa'][MC]
            - $coef1['versa'][7] - $coef2['versa'][7];
        $planet1 = $data1['details2'];
        $planet2 = $data2['details2'];
        if (isset($planet1['planets'][7]['phase']['7-' . ASC]) && in_array($planet1['planets'][7]['phase']['7-' . ASC]['phase_e'], [0, 180]))
        {
            $ret *= 0.8;
        }
        if (isset($planet1['planets'][7]['phase']['7-' . MC]) && in_array($planet1['planets'][7]['phase']['7-' . MC]['phase_e'], [0, 180]))
        {
            $ret *= 0.8;
        }
        if (isset($planet2['planets'][7]['phase']['7-' . ASC]) && in_array($planet2['planets'][7]['phase']['7-' . ASC]['phase_e'], [0, 180]))
        {
            $ret *= 0.8;
        }
        if (isset($planet2['planets'][7]['phase']['7-' . MC]) && in_array($planet2['planets'][7]['phase']['7-' . MC]['phase_e'], [0, 180]))
        {
            $ret *= 0.8;
        }

        return $ret;
    }

    /**
     * 亲密指数
     * 基数=月亮正指数-月亮负指数
     * 若存在月合上升、日月合拱六分、月月合拱六分、月金合拱六分，每多一组则+30*相位系数*容许系数；
     * 若双方月亮都与对方日月金木之一成合拱六分，且除日月金水木上升中天的合拱六分外无其它相位，+50
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     * @return float
     */
    protected function getTheintimateScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);
        $ret += $coef1['obverse'][1] + $coef2['obverse'][1] - $coef1['versa'][1] - $coef2['versa'][1];

        $planets1 = $data1['details2']['planets'];
        $planets2 = $data2['details2']['planets'];
        $phase_e = 0;
        // 若存在月合上升、日月合拱六分、月月合拱六分、月金合拱六分，每多一组则+30*相位系数*容许系数；
        // 月上升
        if (isset($planets1[1]['phase']['1-' . ASC]) && $planets1[1]['phase']['1-' . ASC]['phase_e'] == 0)
        {
            $_e = $planets1[1]['phase']['1-' . ASC]['phase_e'];
            $_orb = $planets1[1]['phase']['1-' . ASC]['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 上升月
        if (isset($planets1[ASC]['phase'][ASC . '-1']) && $planets1[ASC]['phase'][ASC . '-1']['phase_e'] == 0)
        {
            $_e = $planets1[ASC]['phase'][ASC . '-1']['phase_e'];
            $_orb = $planets1[ASC]['phase'][ASC . '-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 月月
        if (isset($planets1[1]['phase']['1-1']) && in_array($planets1[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
        {
            $_e = $planets1[1]['phase']['1-1']['phase_e'];
            $_orb = $planets1[1]['phase']['1-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 日月
        if (isset($planets1[0]['phase']['0-1']) && in_array($planets1[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
        {
            $_e = $planets1[0]['phase']['0-1']['phase_e'];
            $_orb = $planets1[0]['phase']['0-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 月日
        if (isset($planets1[1]['phase']['1-0']) && in_array($planets1[1]['phase']['1-0']['phase_e'], [0, 60, 120]))
        {
            $_e = $planets1[1]['phase']['1-0']['phase_e'];
            $_orb = $planets1[1]['phase']['1-0']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 月金
        if (isset($planets1[1]['phase']['1-3']) && in_array($planets1[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
        {
            $_e = $planets1[1]['phase']['1-3']['phase_e'];
            $_orb = $planets1[1]['phase']['1-3']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 金月
        if (isset($planets1[3]['phase']['3-1']) && in_array($planets1[3]['phase']['3-1']['phase_e'], [0, 60, 120]))
        {
            $_e = $planets1[3]['phase']['3-1']['phase_e'];
            $_orb = $planets1[3]['phase']['3-1']['phase_orb'];
            if ($_e == 0) $phase_e = 1;
            elseif ($_e == 60) $phase_e = 0.75;
            elseif ($_e == 120) $phase_e = 0.85;
            elseif ($_e == 180) $phase_e = 0.9;
            if ($_orb < 0.5) $phase_o = 1;
            elseif ($_orb < 1.5) $phase_o = 0.9;
            elseif ($_orb < 3) $phase_o = 0.85;
            elseif ($_orb <= 5) $phase_o = 0.8;
            elseif ($_orb > 5) $phase_o = 0.75;
            $ret += 30 * $phase_e * $phase_o;
        }
        // 若一方月亮是该星盘中与对方日月金水火四轴非刑相最多的星体且非刑相不少于3个，+25
        $foreach_list = [0, 1, 2, 3, 4, ASC, MC];
        $no_90_1 = $no_90_2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
        for ($i = 0; $i < 10; $i++)
        {
            foreach ($foreach_list as $fl)
            {
                if (isset($planets1[$fl]['phase'][$fl . '-' . $i]) && $planets1[$fl]['phase'][$fl . '-' . $i]['phase_e'] != 90)
                {
                    $no_90_1[$i]++;
                }
                if (isset($planets2[$fl]['phase'][$fl . '-' . $i]) && $planets2[$fl]['phase'][$fl . '-' . $i]['phase_e'] != 90)
                {
                    $no_90_2[$i]++;
                }
            }
        }
        $max_90_num_1 = max($no_90_1);
        $max_90_num_2 = max($no_90_2);
        if (($max_90_num_1 >= 3 && $max_90_num_1 == $no_90_1[1]) || ($max_90_num_2 >= 3 && $max_90_num_2 == $no_90_2[1]))
        {
            $ret += 25;
        }
        // 若双方月亮在同一星座，亲密低于40者令其=40；
        // 若双方月亮在同象星座，亲密低于25者令其=25；
        // 若双方月亮均无月火土天刑冲相，亲密低于30者都令其=30
        if ($planets1[1]['in_sign_id'] == $planets2[1]['in_sign_id'] && $ret < 40)
        {
            $ret = 40;
        } elseif (
            (!isset($planets1[1]['phase']['1-1']) || !in_array($planets1[1]['phase']['1-1']['phase_e'], [90, 180]))
            && (!isset($planets1[1]['phase']['1-4']) || !in_array($planets1[1]['phase']['1-4']['phase_e'], [90, 180]))
            && (!isset($planets1[1]['phase']['1-6']) || !in_array($planets1[1]['phase']['1-6']['phase_e'], [90, 180]))
            && (!isset($planets1[1]['phase']['1-7']) || !in_array($planets1[1]['phase']['1-7']['phase_e'], [90, 180]))
            && (!isset($planets2[1]['phase']['1-1']) || !in_array($planets2[1]['phase']['1-1']['phase_e'], [90, 180]))
            && (!isset($planets2[1]['phase']['1-4']) || !in_array($planets2[1]['phase']['1-4']['phase_e'], [90, 180]))
            && (!isset($planets2[1]['phase']['1-6']) || !in_array($planets2[1]['phase']['1-6']['phase_e'], [90, 180]))
            && (!isset($planets2[1]['phase']['1-7']) || !in_array($planets2[1]['phase']['1-7']['phase_e'], [90, 180]))
            && $ret < 30
        )
        {
            $ret = 30;
        } elseif ($planets1[1]['in_sign_id'] % 4 == $planets2[1]['in_sign_id'] % 4 && $ret < 25)
        {
            $ret = 25;
        }

        return $ret;
    }

    /**
     * 愉悦指数
     * 基数=木星正指数+金星正指数+月亮正指数-金星负指数-月亮负指数
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     * @return int
     */
    protected function getTheHappyScore($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);
        $ret += $coef1['obverse'][5] + $coef2['obverse'][5] + $coef1['obverse'][3] + $coef2['obverse'][3]
            + $coef1['obverse'][1] + $coef2['obverse'][1]
            - $coef1['versa'][1] - $coef2['versa'][1] - $coef1['versa'][3] - $coef2['versa'][3];

        return $ret;
    }

    /**
     * 缘分指数
     * #####基数=（A、M、日、月、金、水、火的正指数合+北交点正指数*3）*和谐度百分比
     * 基数=A、M的正指数合+北交点正指数*2
     * @param array $data1
     * @param array $data2
     * @param bool $debug
     */
    protected function getTheProbTobeLover($data1 = [], $data2 = [], $debug = false)
    {
        $ret = 0;
        $coef1 = $this->getThePrimingScore($data1);
        $coef2 = $this->getThePrimingScore($data2);
        $hc = $this->getTheHarmoniousAndConflict($data1, $data2);
        $ret += (
            $coef1['obverse'][ASC] + $coef2['obverse'][ASC]
            + $coef1['obverse'][MC] + $coef2['obverse'][MC]
            + ($coef1['obverse'][12] + $coef2['obverse'][12]) * 2
        );

        return $ret;
    }

    /**
     * 关系模式判定
     * @param array $data1
     * @param array $data2
     * @param int $attract 吸引指数
     * @param int $chat 沟通指数
     * @param int $passion 激情指数
     * @param int $benefit 信赖指数
     * @param int $happy 愉悦指数
     * @param int $probTobeLover 缘分指数
     * @param bool $debug
     * @return array
     */
    protected function getTheRelation($data1 = [], $data2 = [], $attract = 1, $chat = 1, $passion = 1,
                                      $benefit = 1, $happy = 1, $probTobeLover = 1, $debug = false)
    {
        $mainPhase = $this->getTheMainPhase($data1, $data2);

        $keya = array_search(max($mainPhase['influ']['a']), $mainPhase['influ']['a']);// a对b
        $keyb = array_search(max($mainPhase['influ']['b']), $mainPhase['influ']['b']);// b对a
        $keyc = array_search(max($mainPhase['influ']['c']), $mainPhase['influ']['c']);// 内外相加后
        if ($debug) echo "甲对乙：行星$keya\n乙对甲：行星$keyb\n内外相加：行星$keyc\n";

        $harmoniousAndConflict = $this->getTheHarmoniousAndConflict($data1, $data2);// 和谐冲突度

        $housePower = $this->getTheHousePower($data1, $data2);// 宫位能量

        $planets1 = $data1['details2']['planets'];// A
        $planets2 = $data2['details2']['planets'];// B
        $pls1 = $data1['details1']['planets'];
        $pls2 = $data2['details1']['planets'];
        $relations = [];

        // 异性  1男2女
        if ($this->sex1 != $this->sex2 && in_array($this->sex1, [1, 2]) && in_array($this->sex2, [1, 2]))
        {
            // 双方金星不互相刑冲  且 双方火星不相互刑冲
            if (
                ((!isset($planets1[3]['phase']['3-3']) || !in_array($planets1[3]['phase']['3-3']['phase_e'], [90, 180]))
                    && (!isset($planets1[4]['phase']['4-4']) || !in_array($planets1[4]['phase']['4-4']['phase_e'], [90, 180])))
                || ($attract >= 30 || $benefit >= 30)
            )
            {
                // 恋人关系成立
                if (
                    (
                        (isset($planets1[0]['phase']['0-1']) && $planets1[0]['phase']['0-1']['phase_e'] != 90)
                        || (isset($planets2[0]['phase']['0-1']) && $planets2[0]['phase']['0-1']['phase_e'] != 90)
                    )
                    ||
                    (
                        (isset($planets1[0]['phase']['0-' . ASC]) && in_array($planets1[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets1[0]['phase']['0-' . MC]) && in_array($planets1[0]['phase']['0-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets2[0]['phase']['0-' . ASC]) && in_array($planets2[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets2[0]['phase']['0-' . MC]) && in_array($planets2[0]['phase']['0-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets1[1]['phase']['1-' . ASC]) && in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets1[1]['phase']['1-' . MC]) && in_array($planets1[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets2[1]['phase']['1-' . ASC]) && in_array($planets2[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets2[1]['phase']['1-' . MC]) && in_array($planets2[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets1[3]['phase']['3-' . ASC]) && in_array($planets1[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets1[3]['phase']['3-' . MC]) && in_array($planets1[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets2[3]['phase']['3-' . ASC]) && in_array($planets2[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets2[3]['phase']['3-' . MC]) && in_array($planets2[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                    )
                    ||
                    (
                        (isset($planets1[3]['phase']['3-0']) && $planets1[3]['phase']['3-0']['phase_e'] != 90)
                        || (isset($planets1[3]['phase']['3-1']) && $planets1[3]['phase']['3-1']['phase_e'] != 90)
                        || (isset($planets1[3]['phase']['3-3']) && $planets1[3]['phase']['3-3']['phase_e'] != 90)
                        || (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] != 90)
                        || (isset($planets2[3]['phase']['3-0']) && $planets2[3]['phase']['3-0']['phase_e'] != 90)
                        || (isset($planets2[3]['phase']['3-1']) && $planets2[3]['phase']['3-1']['phase_e'] != 90)
                        || (isset($planets2[3]['phase']['3-3']) && $planets2[3]['phase']['3-3']['phase_e'] != 90)
                        || (isset($planets2[3]['phase']['3-4']) && $planets2[3]['phase']['3-4']['phase_e'] != 90)
                    )
                )
                {
                    $lover_percent = $harmoniousAndConflict[0] * ($attract + $passion + $benefit) / 300 / 70;
                    $relations[] = [$lover_percent, '恋人', 'love'];
                    if ($debug) echo "恋人关系概率为:$lover_percent\n";
                    // 夫妻关系
                    if (
                        $benefit > 60
                        ||
                        (
                            (isset($planets1[0]['phase']['0-1']) && $planets1[0]['phase']['0-1']['phase_e'] != 90)
                            || (isset($planets2[0]['phase']['0-1']) && $planets2[0]['phase']['0-1']['phase_e'] != 90)
                        )
                        ||
                        (
                            ((isset($planets1[0]['phase']['0-' . ASC]) && in_array($planets1[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                                || (isset($planets1[0]['phase']['0-' . MC]) && in_array($planets1[0]['phase']['0-' . MC]['phase_e'], [0, 180]))
                                || (isset($planets2[0]['phase']['0-' . ASC]) && in_array($planets2[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                                || (isset($planets2[0]['phase']['0-' . MC]) && in_array($planets2[0]['phase']['0-' . MC]['phase_e'], [0, 180])))
                            && ((isset($planets1[1]['phase']['1-' . ASC]) && in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                                || (isset($planets1[1]['phase']['1-' . MC]) && in_array($planets1[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                                || (isset($planets2[1]['phase']['1-' . ASC]) && in_array($planets2[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                                || (isset($planets2[1]['phase']['1-' . MC]) && in_array($planets2[1]['phase']['1-' . MC]['phase_e'], [0, 180])))
                        )
                    )
                    {
                        $cp = ($attract + $benefit + $passion) / 300;
//                        $relations['cp'][0] = $cp;
                        $relations[] = [$cp, '夫妻', 'cp'];
                        if ($debug) echo "夫妻关系概率为:$cp\n";
                    }
                    // 灵魂伴侣 恋人，且亲密高于75
                    if ($benefit > 75)
                    {
                        // 0.015*亲密*亲密/（亲密+激情）
                        $soul = 0.011 * $benefit * $benefit / ($benefit + $passion);
                        $relations[] = [$soul, '灵魂伴侣', 'soul'];
                        if ($debug) echo "灵魂伴侣关系概率为:$soul\n";
                    }
                    // 单相思
                    // 符合恋人条件，但一方月亮在对方12宫与天王或土星成相，或一方月亮仅有天王星土星的相位，或一方金星空相，或一方月亮空相，或一方金星仅有土星刑冲
                    if (
                        (
                            $planets1[1]['in_house_id'] == 12
                            && (isset($planets1[1]['phase']['1-6']) || isset($planets1[1]['phase']['1-7']))
                        )
                        ||
                        (
                            $planets2[1]['in_house_id'] == 12
                            && (isset($planets2[1]['phase']['1-6']) || isset($planets2[1]['phase']['1-7']))
                        )
                        || empty($planets1[1]['phase'])
                        || empty($planets2[1]['phase'])
                        || empty($planets1[3]['phase'])
                        || empty($planets2[3]['phase'])
                        ||
                        (
                            (
                                count($planets1[1]['phase']) == 1
                                && (isset($planets1[1]['phase']['1-6']) || isset($planets1[1]['phase']['1-7']))
                            )
                            ||
                            (
                                count($planets1[1]['phase']) == 2
                                && isset($planets1[1]['phase']['1-6']) && isset($planets1[1]['phase']['1-7'])
                            )
                            ||
                            (
                                count($planets2[1]['phase']) == 1
                                && (isset($planets2[1]['phase']['1-6']) || isset($planets2[1]['phase']['1-7']))
                            )
                            ||
                            (
                                count($planets2[1]['phase']) == 2
                                && isset($planets2[1]['phase']['1-6']) && isset($planets2[1]['phase']['1-7'])
                            )
                        )
                        ||
                        (
                            count($planets1[3]['phase']) == 1
                            &&
                            (
                                isset($planets1[3]['phase']['3-6']) && in_array($planets1[3]['phase']['3-6']['phase_e'], [90, 180])
                            )
                        )
                        ||
                        (
                            count($planets2[3]['phase']) == 1
                            &&
                            (
                                isset($planets2[3]['phase']['3-6']) && in_array($planets2[3]['phase']['3-6']['phase_e'], [90, 180])
                            )
                        )
                    )
                    {
                        // 吸引/（亲密+吸引）
                        // 或
                        // 激情/（亲密+激情）【取两者之中的较大者】
                        $miss1 = $attract / ($benefit + $attract);
                        $miss2 = $passion / ($benefit + $passion);
                        $miss = $miss1 > $miss2 ? $miss1 : $miss2;
                        $relations[] = [$miss, '单相思', 'miss'];
                        if ($debug) echo "单相思关系概率为:$miss\n";
                    }
                    // 孽缘
                    // 恋人，且吸引亲密激情之一高于50，且双方日月之一落对方8或12宫或底色为冥王或海王
                    if (
                        ($attract > 50 || $passion > 50 || $benefit > 50)
                        &&
                        (
                            $keyc == 8 || $keyc == 9
                            ||
                            (
                                (
                                    in_array($planets1[0]['in_house_id'], [8, 12])
                                    || in_array($planets1[1]['in_house_id'], [8, 12])
                                )
                                &&
                                (
                                    in_array($planets2[0]['in_house_id'], [8, 12])
                                    || in_array($planets2[1]['in_house_id'], [8, 12])
                                )
                            )
                        )
                    )
                    {
                        // （恋人百分数+吸引/亲密/激情之最高项）/（100+吸引/亲密/激情之最高项）
                        $max_score = max([$attract, $benefit, $passion]);// 吸引/亲密/激情之最高项
                        $evil = ($lover_percent * 100 + $max_score) / ($max_score + 100);
                        $relations[] = [$evil, '孽缘', 'evil'];
                        if ($debug) echo "孽缘关系概率为:$evil\n";
                    }
                    // 闪电恋+异地恋
                    // 恋人且吸引亲密激情之一高于50，双方的金星或月亮之一都与对方天王成相，或者天王合轴
                    // 此时若一方日月金火之一落对方9宫，则为【异地恋】，否则是【闪电恋】===闪电恋+异地恋
                    if (
                        (
                            (
                                (isset($planets1[1]['phase']['1-7']) && $planets1[1]['phase']['1-7']['phase_orb'] <= 2)
                                || (isset($planets1[3]['phase']['3-7']) && $planets1[3]['phase']['3-7']['phase_orb'] <= 2)
                                || (isset($planets1[7]['phase']['7-' . ASC])
                                    && in_array($planets1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                                    && $planets1[7]['phase']['7-' . ASC]['phase_orb'] <= 2
                                )
                                || (isset($planets1[7]['phase']['7-' . MC])
                                    && in_array($planets1[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                                    && $planets1[7]['phase']['7-' . MC]['phase_orb'] <= 2
                                )

                            )
                            &&
                            (
                                (isset($planets2[1]['phase']['1-7']) && $planets2[1]['phase']['1-7']['phase_orb'] <= 2)
                                || (isset($planets2[3]['phase']['3-7']) && $planets2[3]['phase']['3-7']['phase_orb'] <= 2)
                                || (isset($planets2[7]['phase']['7-' . ASC])
                                    && in_array($planets2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                                    && $planets2[7]['phase']['7-' . ASC]['phase_orb'] <= 2
                                )
                                || (isset($planets2[7]['phase']['7-' . MC])
                                    && in_array($planets2[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                                    && $planets2[7]['phase']['7-' . MC]['phase_orb'] <= 2
                                )
                            )
                        )
                        &&
                        (
                            $benefit > 50 || $attract > 50 || $passion > 50
                        )
                    )
                    {
                        $fast_love = $mainPhase['influ']['c'][7] / ($mainPhase['influ']['c'][$keyc] + 5);
                        $planets1_2 = $data1['details1']['planets'];
                        $planets2_2 = $data2['details1']['planets'];
                        if (
                            $passion < 30 && $attract > 60 && $benefit > 60
                        )
                        {
//                            $fast_love = ($attract + $chat + $happy + $benefit) / 400;
//                            $relations[] = [$fast_love,'相敬相知','fast_love'];
//                            if($debug) echo "相敬相知关系概率为:$fast_love\n";
                        } elseif (
                            $planets1[0]['in_house_id'] == 9
                            || $planets1[1]['in_house_id'] == 9
                            || $planets1[3]['in_house_id'] == 9
                            || $planets1[4]['in_house_id'] == 9
                            || $planets2[0]['in_house_id'] == 9
                            || $planets2[1]['in_house_id'] == 9
                            || $planets2[3]['in_house_id'] == 9
                            || $planets2[4]['in_house_id'] == 9
                            || $planets1_2[3]['in_house_id'] == 9
                            || $planets1_2[4]['in_house_id'] == 9
                            || $planets2_2[3]['in_house_id'] == 9
                            || $planets2_2[4]['in_house_id'] == 9
                        )
                        {
                            $relations[] = [$fast_love, '异地恋', 'fast_love'];
                            if ($debug) echo "异地恋关系概率为:$fast_love\n";
                        } else
                        {
                            $relations[] = [$fast_love, '闪电恋', 'fast_love'];
                            if ($debug) echo "闪电恋关系概率为:$fast_love\n";
                        }
                    }
                    // 欢喜冤家
                    // 恋人，火星合轴，或存在日火冲或月火冲
                    if (
                        (isset($planets1[4]['phase']['4-' . ASC]) && in_array($planets1[4]['phase']['4-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets1[4]['phase']['4-' . MC]) && in_array($planets1[4]['phase']['4-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets1[0]['phase']['0-4']) && $planets1[0]['phase']['0-4']['phase_e'] == 180)
                        || (isset($planets1[1]['phase']['1-4']) && $planets1[1]['phase']['1-4']['phase_e'] == 180)
                        || (isset($planets2[4]['phase']['4-' . ASC]) && in_array($planets2[4]['phase']['4-' . ASC]['phase_e'], [0, 180]))
                        || (isset($planets2[4]['phase']['4-' . MC]) && in_array($planets2[4]['phase']['4-' . MC]['phase_e'], [0, 180]))
                        || (isset($planets2[0]['phase']['0-4']) && $planets2[0]['phase']['0-4']['phase_e'] == 180)
                        || (isset($planets2[1]['phase']['1-4']) && $planets2[1]['phase']['1-4']['phase_e'] == 180)

                    )
                    {
                        // （恋人百分数+火星影响值）/（100+火星影响值）
                        $foe = ($lover_percent * 100 + $mainPhase['influ']['c'][4]) / (100 + $mainPhase['influ']['c'][4]);
                        $relations[] = [$foe, '欢喜冤家', 'foe'];
                        if ($debug) echo "欢喜冤家关系概率为:$foe\n";
                    }
                    // 暧昧
                    // 恋人，双方的金星或月亮之一，都与对方海王成相，或者海王合轴；【亲密低于30】
                    if (
                        ((
                                isset($planets1[1]['phase']['1-8'])
                                || isset($planets1[3]['phase']['3-8'])
                                || (isset($planets1[8]['phase']['8-' . ASC])
                                    && in_array($planets1[8]['phase']['8-' . ASC]['phase_e'], [0, 180])
                                    && $planets1[8]['phase']['8-' . ASC]['phase_orb'] <= 2
                                )
                                || (isset($planets1[8]['phase']['8-' . MC])
                                    && in_array($planets1[8]['phase']['8-' . MC]['phase_e'], [0, 180])
                                    && $planets1[8]['phase']['8-' . MC]['phase_orb'] <= 2
                                )

                            )
                            ||
                            (
                                isset($planets2[1]['phase']['1-8'])
                                || isset($planets2[3]['phase']['3-8'])
                                || (isset($planets2[8]['phase']['8-' . ASC]) && in_array($planets2[8]['phase']['8-' . ASC]['phase_e'], [0, 180]))
                                || (isset($planets2[8]['phase']['8-' . MC]) && in_array($planets2[8]['phase']['8-' . MC]['phase_e'], [0, 180]))
                            ))
                        &&
                        (
                            $benefit < 30
                        )
                    )
                    {
                        // 海王星影响值/（底色星体影响值+10）
//                        p($mainPhase['influ']['c']);
                        $ambiguity = $mainPhase['influ']['c'][8] / (10 + $mainPhase['influ']['c'][$keyc]);
                        $relations[] = [$ambiguity, '暧昧', 'ambiguity'];
                        if ($debug) echo "暧昧关系概率为:$ambiguity\n";
                    }
                    // 恋人，且激情不小于50，且双方本命金火不成相或双方年龄均小于18，
                    // 且双方满足本命以下条件之一：1、金星与土星成相；2、金星与天王成相；3、金星在天蝎、摩羯、水瓶、处女
                    // 且双方满足以下条件之一：1、火星与土星合刑冲且不在火象星座；2、火星在摩羯或金牛或处女或巨蟹
                    if (
                        $passion >= 50
                        &&
                        (
                            (!isset($pls1[3]['or_phase']['3-4']) && !isset($pls2[3]['or_phase']['3-4']))
                            ||
                            (time() - $this->timestamp1 < 18 * 365 * 24 * 3600 && time() - $this->timestamp2 < 18 * 365 * 24 * 3600)
                        )
                        &&
                        (
                            (
                                isset($pls1[3]['or_phase']['3-6'])
                                || isset($pls1[3]['or_phase']['3-7'])
                                || in_array($pls1[3]['in_sign_id'], [6, 8, 10, 11])
                            )
                            &&
                            (
                                isset($pls2[3]['or_phase']['3-6'])
                                || isset($pls2[3]['or_phase']['3-7'])
                                || in_array($pls2[3]['in_sign_id'], [6, 8, 10, 11])
                            )
                        )
                        &&
                        (
                            (
                                (
                                    isset($pls1[4]['phase']['4-6'])
                                    && in_array($pls1[4]['phase']['4-6']['phase_e'], [0, 90, 180])
                                    && $pls1[4]['in_sign_id'] % 4 != 1
                                    && $pls2[6]['in_sign_id'] % 4 != 1
                                )
                                ||
                                in_array($pls1[4]['in_sign_id'], [2, 4, 6, 10])
                            )
                            &&
                            (
                                (
                                    isset($pls2[4]['phase']['4-6'])
                                    && in_array($pls2[4]['phase']['4-6']['phase_e'], [0, 90, 180])
                                    && $pls2[4]['in_sign_id'] % 4 != 1
                                    && $pls1[6]['in_sign_id'] % 4 != 1
                                )
                                ||
                                in_array($pls2[4]['in_sign_id'], [2, 4, 6, 10])
                            )
                        )
                    )
                    {
                        // （激情+ 吸引）    / (激情+吸引+沟通)
                        $anlian = ($passion + $attract) / ($passion + $attract + $chat);
                        $relations[] = [$anlian, '暗恋', 'anlian'];
                        if ($debug) echo "暗恋关系概率为:$anlian\n";
                    }
                }
            } // 炮友关系   --- 情人关系
            elseif (
                ($passion > 60 && $benefit < 40 && $chat < 40) && (
                    (isset($planets1[4]['phase']['4-3']) && $planets1[4]['phase']['4-3']['phase_e'] != 90)
                    || (isset($planets1[4]['phase']['4-4']) && $planets1[4]['phase']['4-4']['phase_e'] != 90)
                    || (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] != 90)
                )
            )
            {
                $py = 0.02 * $passion * $passion / ($passion + $benefit);
                $relations[] = [$py, '情人', 'py'];
                if ($debug) echo "情人关系概率为:$py\n";
            }
            // 地下情 （前世情人）
            if (
                (
                    (
                        $planets1[0]['in_house_id'] == 12
                        || $planets1[1]['in_house_id'] == 12
                        || $planets1[3]['in_house_id'] == 12
                        || $planets1[ASC]['in_house_id'] == 12
                    )
                    ||
                    (
                        $planets2[0]['in_house_id'] == 12
                        || $planets2[1]['in_house_id'] == 12
                        || $planets2[3]['in_house_id'] == 12
                        || $planets2[ASC]['in_house_id'] == 12
                    )

                )
                &&
                (
                    isset($planets1[1]['phase']['1-8'])
                    || isset($planets1[1]['phase']['1-9'])
                    || isset($planets1[3]['phase']['3-8'])
                    || isset($planets1[3]['phase']['3-9'])
                    || isset($planets2[1]['phase']['1-8'])
                    || isset($planets2[1]['phase']['1-9'])
                    || isset($planets2[3]['phase']['3-8'])
                    || isset($planets2[3]['phase']['3-9'])
                )
                &&
                (
                    (isset($planets1[0]['phase']['0-1']) && $planets1[0]['phase']['0-1']['phase_e'] != 90)
                    || (isset($planets2[0]['phase']['0-1']) && $planets2[0]['phase']['0-1']['phase_e'] != 90)
                    || (isset($planets1[3]['phase']['3-4']) && $planets1[3]['phase']['3-4']['phase_e'] != 90)
                    || (isset($planets2[3]['phase']['3-4']) && $planets2[3]['phase']['3-4']['phase_e'] != 90)
                )
            )
            {
                // 处理为定义数组下标9
                $mainPhase_influ_c_9 = isset($mainPhase['influ']['c'][9]) ? $mainPhase['influ']['c'][9] : 0;

                $secret = ($mainPhase['influ']['c'][8] + $mainPhase_influ_c_9) / (20 + $mainPhase['influ']['c'][8] + $mainPhase_influ_c_9);
                $relations[] = [$secret, '前世情人', 'secret'];
                if ($debug) echo "前世情人关系概率为:$secret\n";
            }
        }
        // 路人 日月金水火无相位或仅金水火有1-2个且日月金不合轴
        if (
            (
                empty($planets1[0]['phase'])
                && empty($planets1[1]['phase'])
                && empty($planets1[2]['phase'])
                && empty($planets1[3]['phase'])
                && empty($planets1[4]['phase'])
                && empty($planets2[0]['phase'])
                && empty($planets2[1]['phase'])
                && empty($planets2[2]['phase'])
                && empty($planets2[3]['phase'])
                && empty($planets2[4]['phase'])
            )
            ||
            (
                in_array(
                    count($planets1[2]['phase'])
                    + count($planets1[3]['phase'])
                    + count($planets1[4]['phase'])
                    + count($planets2[2]['phase'])
                    + count($planets2[3]['phase'])
                    + count($planets2[4]['phase'])
                    , [1, 2]
                )
                &&
                (
                    (!isset($planets1[0]['phase']['0-' . ASC]) || !in_array($planets1[0]['phase']['0-' . ASC]['phase_e'], [0, 180]))
                    && (!isset($planets1[0]['phase']['0-' . MC]) || !in_array($planets1[0]['phase']['0-' . MC]['phase_e'], [0, 180]))
                    && (!isset($planets1[1]['phase']['1-' . ASC]) || !in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
                    && (!isset($planets1[1]['phase']['1-' . MC]) || !in_array($planets1[1]['phase']['1-' . MC]['phase_e'], [0, 180]))
                    && (!isset($planets1[3]['phase']['3-' . ASC]) || !in_array($planets1[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                    && (!isset($planets1[3]['phase']['3-' . MC]) || !in_array($planets1[3]['phase']['3-' . MC]['phase_e'], [0, 180]))
                )
            )
        )
        {
            // 1-有相位的个人星个数/11
            $preson_num = 0;
            if (count($planets1[0]['phase'])) $preson_num++;
            if (count($planets1[1]['phase'])) $preson_num++;
            if (count($planets1[2]['phase'])) $preson_num++;
            if (count($planets1[3]['phase'])) $preson_num++;
            if (count($planets1[4]['phase'])) $preson_num++;
            if (count($planets2[0]['phase'])) $preson_num++;
            if (count($planets2[1]['phase'])) $preson_num++;
            if (count($planets2[2]['phase'])) $preson_num++;
            if (count($planets2[3]['phase'])) $preson_num++;
            if (count($planets2[4]['phase'])) $preson_num++;
            $passerby = 1 - ($preson_num / 11);
            $relations[] = [$passerby, '路人', 'passerby'];
            if ($debug) echo "路人关系概率为:$passerby\n";
        }
        // 知己 亲密度大于6 0，吸引不低于40，且无金火、火火相位
        if ($attract >= 40 && $benefit > 60
            && !isset($planets1[3]['phase']['3-4'])
            && !isset($planets1[3]['phase']['3-3'])
            && !isset($planets2[3]['phase']['3-4']))
        {
            // （亲密+吸引）/（亲密+吸引+冲突度*2）
            $jugate = ($attract + $benefit) / ($attract + $benefit + $harmoniousAndConflict[1] * 2);
            $relations[] = [$jugate, '知己', 'jugate'];
            if ($debug) echo "知己关系概率为:$jugate\n";
        }
        // 师生(良师益友) 一方太阳或月亮与对方土星成非刑相，且存在日水、月水、水水、水木的非刑相，且一方日月水金火之一落对方3或9宫
        if (
        (
            (
                (isset($planets1[6]['phase']['6-0']) && $planets1[6]['phase']['6-0']['phase_e'] != 90)
                || (isset($planets1[6]['phase']['6-1']) && $planets1[6]['phase']['6-1']['phase_e'] != 90)
                || (isset($planets2[6]['phase']['6-0']) && $planets2[6]['phase']['6-0']['phase_e'] != 90)
                || (isset($planets2[6]['phase']['6-1']) && $planets2[6]['phase']['6-1']['phase_e'] != 90)
            )
            &&
            (
                (isset($planets1[2]['phase']['2-0']) && $planets1[2]['phase']['2-0']['phase_e'] != 90)
                || (isset($planets1[2]['phase']['2-1']) && $planets1[2]['phase']['2-1']['phase_e'] != 90)
                || (isset($planets1[2]['phase']['2-2']) && $planets1[2]['phase']['2-2']['phase_e'] != 90)
                || (isset($planets1[2]['phase']['2-5']) && $planets1[2]['phase']['2-5']['phase_e'] != 90)
                || (isset($planets2[2]['phase']['2-0']) && $planets2[2]['phase']['2-0']['phase_e'] != 90)
                || (isset($planets2[2]['phase']['2-1']) && $planets2[2]['phase']['2-1']['phase_e'] != 90)
                || (isset($planets2[2]['phase']['2-2']) && $planets2[2]['phase']['2-2']['phase_e'] != 90)
                || (isset($planets2[2]['phase']['2-5']) && $planets2[2]['phase']['2-5']['phase_e'] != 90)
            )
            &&
            (
                in_array($planets1[0]['in_house_id'], [3, 9])
                || in_array($planets1[1]['in_house_id'], [3, 9])
                || in_array($planets1[2]['in_house_id'], [3, 9])
                || in_array($planets1[3]['in_house_id'], [3, 9])
                || in_array($planets1[4]['in_house_id'], [3, 9])
                || in_array($planets2[0]['in_house_id'], [3, 9])
                || in_array($planets2[1]['in_house_id'], [3, 9])
                || in_array($planets2[2]['in_house_id'], [3, 9])
                || in_array($planets2[3]['in_house_id'], [3, 9])
                || in_array($planets2[4]['in_house_id'], [3, 9])
            )
        )
        )
        {
            // （沟通+土星影响）/（100+土星影响）
            $teacher = ($chat + $mainPhase['influ']['c'][6]) / (100 + $mainPhase['influ']['c']['6'] + $harmoniousAndConflict[1]);
            $relations[] = [$teacher, '良师益友', 'teacher'];
            if ($debug) echo "良师益友关系概率为:$teacher\n";
        }
        // 竞争对手 双方火星均与对方日月火之一成刑冲相，且一方日月火之一落对方7宫或合下降
        if (
            (
                (isset($planets1['4']['phase']['4-0']) && in_array($planets1['4']['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($planets1['4']['phase']['4-1']) && in_array($planets1['4']['phase']['4-1']['phase_e'], [90, 180]))
                || (isset($planets1['4']['phase']['4-4']) && in_array($planets1['4']['phase']['4-4']['phase_e'], [90, 180]))
            )
            &&
            (
                (isset($planets2['4']['phase']['4-0']) && in_array($planets2['4']['phase']['4-0']['phase_e'], [90, 180]))
                || (isset($planets2['4']['phase']['4-1']) && in_array($planets2['4']['phase']['4-1']['phase_e'], [90, 180]))
                || (isset($planets2['4']['phase']['4-4']) && in_array($planets2['4']['phase']['4-4']['phase_e'], [90, 180]))
            )
            &&
            (
                $planets1[0]['in_house_id'] == 7
                || $planets1[1]['in_house_id'] == 7
                || $planets1[4]['in_house_id'] == 7
                || $planets1[0]['in_house_id'] == 7
                || (isset($planets1[0]['phase']['0-' . ASC]) && $planets1[0]['phase']['0-' . ASC]['phase_e'] == 180)
                || (isset($planets1[1]['phase']['1-' . ASC]) && $planets1[1]['phase']['1-' . ASC]['phase_e'] == 180)
                || (isset($planets1[4]['phase']['4-' . ASC]) && $planets1[4]['phase']['4-' . ASC]['phase_e'] == 180)
                || $planets2[0]['in_house_id'] == 7
                || $planets2[1]['in_house_id'] == 7
                || $planets2[4]['in_house_id'] == 7
                || $planets2[0]['in_house_id'] == 7
                || (isset($planets2[0]['phase']['0-' . ASC]) && $planets2[0]['phase']['0-' . ASC]['phase_e'] == 180)
                || (isset($planets2[1]['phase']['1-' . ASC]) && $planets2[1]['phase']['1-' . ASC]['phase_e'] == 180)
                || (isset($planets2[4]['phase']['4-' . ASC]) && $planets2[4]['phase']['4-' . ASC]['phase_e'] == 180)
            )
        )
        {
            $compete = $mainPhase['influ']['c'][4] / ($mainPhase['influ']['c'][$keyc] + 5);
            $relations[] = [$compete, '竞争对手', 'compete'];
            if ($debug) echo "竞争对手关系概率为:$compete\n";
        }
        // 玩伴 一方太阳或月亮落入对方5宫，且双方日月均无土星相位
        if (
            (
                $planets1[0]['in_house_id'] == 5
                || $planets1[1]['in_house_id'] == 5
                || $planets2[0]['in_house_id'] == 5
                || $planets2[1]['in_house_id'] == 5
            )
            &&
            (
                !isset($planets1[0]['phase']['0-6'])
                && !isset($planets1[1]['phase']['1-6'])
                && !isset($planets2[0]['phase']['0-6'])
                && !isset($planets2[1]['phase']['1-6'])
            )
        )
        {
            // 5宫建设能量/（5宫建设能量+5宫破坏能量+5）
            $player = $housePower[0][5] / ($housePower[0][5] + $housePower[1][5] + 5);
            $relations[] = [$player, '玩伴', 'player'];
            if ($debug) echo "玩伴关系概率为:$player\n";
        }
        // 债主 ######一方太阳或月亮落入对方2或8宫，同时遭遇非三王的刑冲
        // 双方太阳或月亮或金星落入对方2或8宫，并遭遇非三王的刑冲
        $is_90180_01 = false;
        $is_90180_11 = false;
        $is_90180_31 = false;
        $is_90180_02 = false;
        $is_90180_12 = false;
        $is_90180_32 = false;
        if (!empty($planets1[0]['phase']))
        {
            foreach ($planets1[0]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]) && !in_array($ps['id'], [7, 8, 9])) $is_90180_01 = true;
            }
        }
        if (!empty($planets1[1]['phase']))
        {
            foreach ($planets1[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 && !in_array($ps['id'], [7, 8, 9])) $is_90180_11 = true;
            }
        }
        if (!empty($planets1[3]['phase']))
        {
            foreach ($planets1[3]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 && !in_array($ps['id'], [7, 8, 9])) $is_90180_31 = true;
            }
        }
        if (!empty($planets2[0]['phase']))
        {
            foreach ($planets2[0]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 && !in_array($ps['id'], [7, 8, 9])) $is_90180_02 = true;
            }
        }
        if (!empty($planets2[1]['phase']))
        {
            foreach ($planets2[1]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 && !in_array($ps['id'], [7, 8, 9])) $is_90180_12 = true;
            }
        }
        if (!empty($planets2[3]['phase']))
        {
            foreach ($planets2[3]['phase'] as $ps)
            {
                if ($ps['phase_e'] == 90 && !in_array($ps['id'], [7, 8, 9])) $is_90180_32 = true;
            }
        }
        if (
            (
                (in_array($planets1[0]['in_house_id'], [2, 8]) && $is_90180_01)
                || (in_array($planets1[1]['in_house_id'], [2, 8]) && $is_90180_11)
                || (in_array($planets1[3]['in_house_id'], [2, 8]) && $is_90180_31)
            )
            &&
            (
                (in_array($planets2[0]['in_house_id'], [2, 8]) && $is_90180_02)
                || (in_array($planets2[1]['in_house_id'], [2, 8]) && $is_90180_12)
                || (in_array($planets2[3]['in_house_id'], [2, 8]) && $is_90180_32)
            )
        )
        {
            // 2 8宫破坏能量之和/（2 8宫总能量和+5）
            $renter = ($housePower[1][2] + $housePower[1][8]) /
                ($housePower[0][2] + $housePower[1][2] + $housePower[0][8] + $housePower[1][8] + 5);
            $relations[] = [$renter, '债主', 'renter'];
            if ($debug) echo "债主关系概率为:$renter\n";
        }
        // 完美拍档 日月金水火四轴没有任何刑冲
        $pre_90180 = false;
        $dang_90180 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
        if (!empty($planets1[0]['phase']))
        {
            foreach ($planets1[0]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[0]++;
                }
            }
        }
        if (!empty($planets1[1]['phase']))
        {
            foreach ($planets1[1]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[1]++;
                }
            }
        }
        if (!empty($planets1[2]['phase']))
        {
            foreach ($planets1[2]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[2]++;
                }
            }
        }
        if (!empty($planets1[3]['phase']))
        {
            foreach ($planets1[3]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[3]++;
                }
            }
        }
        if (!empty($planets1[4]['phase']))
        {
            foreach ($planets1[4]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[4]++;
                }
            }
        }
        if (!empty($planets1[ASC]['phase']))
        {
            foreach ($planets1[ASC]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [0, 90, 180]) && $ps['id'] >= 7 && $ps['id'] <= 9) $pre_90180 = true;
            }
        }
        if (!empty($planets1[MC]['phase']))
        {
            foreach ($planets1[MC]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [0, 90, 180]) && $ps['id'] >= 7 && $ps['id'] <= 9) $pre_90180 = true;
            }
        }
        if (!empty($planets2[0]['phase']))
        {
            foreach ($planets2[0]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[5]++;
                }
            }
        }
        if (!empty($planets2[1]['phase']))
        {
            foreach ($planets2[1]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[6]++;
                }
            }
        }
        if (!empty($planets2[2]['phase']))
        {
            foreach ($planets2[2]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[7]++;
                }
            }
        }
        if (!empty($planets2[3]['phase']))
        {
            foreach ($planets2[3]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[8]++;
                }
            }
        }
        if (!empty($planets2[4]['phase']))
        {
            foreach ($planets2[4]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [90, 180]))
                {
                    if ($ps['id'] >= 7 && $ps['id'] <= 9)
                        $pre_90180 = true;
                    $dang_90180[9]++;
                }
            }
        }
        if (!empty($planets2[ASC]['phase']))
        {
            foreach ($planets2[ASC]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [0, 90, 180]) && $ps['id'] >= 7 && $ps['id'] <= 9) $pre_90180 = true;
            }
        }
        if (!empty($planets2[MC]['phase']))
        {
            foreach ($planets2[MC]['phase'] as $ps)
            {
                if (in_array($ps['phase_e'], [0, 90, 180]) && $ps['id'] >= 7 && $ps['id'] <= 9) $pre_90180 = true;
            }
        }
        if ($pre_90180 === false)
        {
            // （和谐度+1）/101
            $pre_partner = ($harmoniousAndConflict[0] + 1) / 101;
            $relations[] = [$pre_partner, '完美拍档', 'pre_partner'];
            if ($debug) echo "完美拍档关系概率为:$pre_partner\n";
        }
        // 危险关系(敌人)（冤家对头） 【前提：木星不合轴】双方日月金水火都有刑冲，或有火星冥王同时合轴，或有火星天王同时合轴，或有火星冥王同时刑冲对方日月
        $dang_90180 = array_filter($dang_90180);// 去除无刑冲相位的
        if (
            count($dang_90180) == 10
            ||
            (
                (
                    (isset($planets1[4]['phase']['4-' . ASC])
                        && in_array($planets1[4]['phase']['4-' . ASC]['phase_e'], [0, 180]))
                    || (isset($planets1[4]['phase']['4-' . MC])
                        && in_array($planets1[4]['phase']['4-' . MC]['phase_e'], [0, 180]))
                    || (isset($planets2[4]['phase']['4-' . ASC])
                        && in_array($planets2[4]['phase']['4-' . ASC]['phase_e'], [0, 180]))
                    || (isset($planets2[4]['phase']['4-' . MC])
                        && in_array($planets2[4]['phase']['4-' . MC]['phase_e'], [0, 180]))
                )
                &&
                (
                    (
                        (
                            isset($planets1[7]['phase']['7-' . ASC])
                            && in_array($planets1[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                            && $planets1[7]['phase']['7-' . ASC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets1[7]['phase']['7-' . MC])
                            && in_array($planets1[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                            && $planets1[7]['phase']['7-' . MC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets2[7]['phase']['7-' . ASC])
                            && in_array($planets2[7]['phase']['7-' . ASC]['phase_e'], [0, 180])
                            && $planets2[7]['phase']['7-' . ASC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets2[7]['phase']['7-' . MC])
                            && in_array($planets2[7]['phase']['7-' . MC]['phase_e'], [0, 180])
                            && $planets2[7]['phase']['7-' . MC]['phase_orb'] <= 2
                        )
                    )
                    ||
                    (
                        (
                            isset($planets1[9]['phase']['9-' . ASC])
                            && in_array($planets1[9]['phase']['9-' . ASC]['phase_e'], [0, 180])
                            && $planets1[9]['phase']['9-' . ASC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets1[9]['phase']['9-' . MC])
                            && in_array($planets1[9]['phase']['9-' . MC]['phase_e'], [0, 180])
                            && $planets1[9]['phase']['9-' . MC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets2[9]['phase']['9-' . ASC])
                            && in_array($planets2[9]['phase']['9-' . ASC]['phase_e'], [0, 180])
                            && $planets2[9]['phase']['9-' . ASC]['phase_orb'] <= 2
                        )
                        ||
                        (
                            isset($planets2[9]['phase']['9-' . MC])
                            && in_array($planets2[9]['phase']['9-' . MC]['phase_e'], [0, 180])
                            && $planets2[9]['phase']['9-' . MC]['phase_orb'] <= 2
                        )
                    )
                )
            )
            ||
            (
                (
                    (
                        (isset($planets1[4]['phase']['4-0']) && in_array($planets1[4]['phase']['4-0']['phase_e'], [90, 180]))
                        && (isset($planets2[4]['phase']['4-0']) && in_array($planets2[4]['phase']['4-0']['phase_e'], [90, 180]))
                    )
                    ||
                    (
                        (isset($planets1[4]['phase']['4-1']) && in_array($planets1[4]['phase']['4-1']['phase_e'], [90, 180]))
                        && (isset($planets2[4]['phase']['4-1']) && in_array($planets2[4]['phase']['4-1']['phase_e'], [90, 180]))
                    )
                )
                &&
                (
                    (
                        (isset($planets1[9]['phase']['9-0']) && in_array($planets1[9]['phase']['9-0']['phase_e'], [90, 180]))
                        && (isset($planets2[9]['phase']['9-0']) && in_array($planets2[9]['phase']['9-0']['phase_e'], [90, 180]))
                    )
                    ||
                    (
                        (isset($planets1[9]['phase']['9-1']) && in_array($planets1[9]['phase']['9-1']['phase_e'], [90, 180]))
                        && (isset($planets2[9]['phase']['9-1']) && in_array($planets2[9]['phase']['9-1']['phase_e'], [90, 180]))
                    )
                )
            )
        )
        {
            if (
                (!isset($planets1[5]['phase']['5-' . ASC]) || !in_array($planets1[5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
                && (!isset($planets1[5]['phase']['5-' . MC]) || !in_array($planets1[5]['phase']['5-' . MC]['phase_e'], [0, 180]))
                && (!isset($planets2[5]['phase']['5-' . ASC]) || !in_array($planets2[5]['phase']['5-' . ASC]['phase_e'], [0, 180]))
                && (!isset($planets2[5]['phase']['5-' . MC]) || !in_array($planets2[5]['phase']['5-' . MC]['phase_e'], [0, 180]))
            )
            {
                // （冲突度+火星影响+冥王影响+天王影响）/（100+火星影响+冥王影响+天王影响）
                // （冲突度+火星影响+冥王影响+天王影响）/（100+火星影响+冥王影响+天王影响+金星影响+木星影响）
                $dangerous = (
                        $harmoniousAndConflict[1]
                        + $mainPhase['influ']['c'][4]
                        + $mainPhase['influ']['c'][7] + $mainPhase['influ']['c'][9]
                    )
                    / (
                        100
                        + $mainPhase['influ']['c'][3]
                        + $mainPhase['influ']['c'][4]
                        + $mainPhase['influ']['c'][5]
                        + $mainPhase['influ']['c'][7]
                        + $mainPhase['influ']['c'][9]
                    );
                $relations[] = [$dangerous, '冤家对头', 'dangerous'];
                if ($debug) echo "冤家对头概率为:$dangerous\n";
            }

        }
        // 泛泛之交
//        if($attract < 25 && $benefit < 25 && $passion < 25 && $happy < 25 && $chat < 25)
        if ($attract < 30 && $benefit < 30 && $probTobeLover < 30 && $chat < 30)
        {
            $acquaintance = (300 - $attract - $benefit - $passion - $chat) / 300;
            $relations[] = [$acquaintance, '泛泛之交', 'acquaintance'];
            if ($debug) echo "泛泛之交关系概率为:$acquaintance\n";
        }
        // 合作伙伴 金星、太阳或月亮、木星底色，MC破坏能量<20 && $housePower[1][10] < 25
        $houses1 = $data1['details2']['houses'];// A
        $houses2 = $data2['details2']['houses'];// B
        $inhouse2_10_11 = false;// 日金是否落入对方2、10、11宫或者宫头前5度
        if (in_array($planets1[0]['in_house_id'], [2, 10, 11])
            || in_array($planets1[3]['in_house_id'], [2, 10, 11])
            || in_array($planets2[0]['in_house_id'], [2, 10, 11])
            || in_array($planets2[3]['in_house_id'], [2, 10, 11])) $inhouse2_10_11 = true;
        if (
            ($houses1[2]['deg'] >= 5 && ($planets1[0]['deg'] <= $houses1[2]['deg'] && $planets1[0]['deg'] >= $houses1[2]['deg'] - 5))
            || ($houses1[2]['deg'] < 5 && ($planets1[0]['deg'] <= $houses1[2]['deg'] || $planets1[0]['deg'] >= 360 - $houses1[2]['deg']))
            || ($houses1[2]['deg'] >= 5 && ($planets1[3]['deg'] <= $houses1[2]['deg'] && $planets1[3]['deg'] >= $houses1[2]['deg'] - 5))
            || ($houses1[2]['deg'] < 5 && ($planets1[3]['deg'] <= $houses1[2]['deg'] || $planets1[3]['deg'] >= 360 - $houses1[2]['deg']))
            || ($houses1[10]['deg'] >= 5 && ($planets1[0]['deg'] <= $houses1[10]['deg'] && $planets1[0]['deg'] >= $houses1[10]['deg'] - 5))
            || ($houses1[10]['deg'] < 5 && ($planets1[0]['deg'] <= $houses1[10]['deg'] || $planets1[0]['deg'] >= 360 - $houses1[10]['deg']))
            || ($houses1[10]['deg'] >= 5 && ($planets1[3]['deg'] <= $houses1[10]['deg'] && $planets1[3]['deg'] >= $houses1[10]['deg'] - 5))
            || ($houses1[10]['deg'] < 5 && ($planets1[3]['deg'] <= $houses1[10]['deg'] || $planets1[3]['deg'] >= 360 - $houses1[10]['deg']))
            || ($houses1[11]['deg'] >= 5 && ($planets1[0]['deg'] <= $houses1[11]['deg'] && $planets1[0]['deg'] >= $houses1[11]['deg'] - 5))
            || ($houses1[11]['deg'] < 5 && ($planets1[0]['deg'] <= $houses1[11]['deg'] || $planets1[0]['deg'] >= 360 - $houses1[11]['deg']))
            || ($houses1[11]['deg'] >= 5 && ($planets1[3]['deg'] <= $houses1[11]['deg'] && $planets1[3]['deg'] >= $houses1[11]['deg'] - 5))
            || ($houses1[11]['deg'] < 5 && ($planets1[3]['deg'] <= $houses1[11]['deg'] || $planets1[3]['deg'] >= 360 - $houses1[11]['deg']))

            || ($houses2[2]['deg'] >= 5 && ($planets2[0]['deg'] <= $houses2[2]['deg'] && $planets2[0]['deg'] >= $houses2[2]['deg'] - 5))
            || ($houses2[2]['deg'] < 5 && ($planets2[0]['deg'] <= $houses2[2]['deg'] || $planets2[0]['deg'] >= 360 - $houses2[2]['deg']))
            || ($houses2[2]['deg'] >= 5 && ($planets2[3]['deg'] <= $houses2[2]['deg'] && $planets2[3]['deg'] >= $houses2[2]['deg'] - 5))
            || ($houses2[2]['deg'] < 5 && ($planets2[3]['deg'] <= $houses2[2]['deg'] || $planets2[3]['deg'] >= 360 - $houses2[2]['deg']))
            || ($houses2[10]['deg'] >= 5 && ($planets2[0]['deg'] <= $houses2[10]['deg'] && $planets2[0]['deg'] >= $houses2[10]['deg'] - 5))
            || ($houses2[10]['deg'] < 5 && ($planets2[0]['deg'] <= $houses2[10]['deg'] || $planets2[0]['deg'] >= 360 - $houses2[10]['deg']))
            || ($houses2[10]['deg'] >= 5 && ($planets2[3]['deg'] <= $houses2[10]['deg'] && $planets2[3]['deg'] >= $houses2[10]['deg'] - 5))
            || ($houses2[10]['deg'] < 5 && ($planets2[3]['deg'] <= $houses2[10]['deg'] || $planets2[3]['deg'] >= 360 - $houses2[10]['deg']))
            || ($houses2[11]['deg'] >= 5 && ($planets2[0]['deg'] <= $houses2[11]['deg'] && $planets2[0]['deg'] >= $houses2[11]['deg'] - 5))
            || ($houses2[11]['deg'] < 5 && ($planets2[0]['deg'] <= $houses2[11]['deg'] || $planets2[0]['deg'] >= 360 - $houses2[11]['deg']))
            || ($houses2[11]['deg'] >= 5 && ($planets2[3]['deg'] <= $houses2[11]['deg'] && $planets2[3]['deg'] >= $houses2[11]['deg'] - 5))
            || ($houses2[11]['deg'] < 5 && ($planets2[3]['deg'] <= $houses2[11]['deg'] || $planets2[3]['deg'] >= 360 - $houses2[11]['deg']))
        )
            $inhouse2_10_11 = true;

        if (
            (in_array($keyc, [0, 1, 3, 5]) && $inhouse2_10_11 === true)
            ||
            (
                (
                    isset($planets1[0]['phase']['0-1'])
                    || isset($planets1[6]['phase']['6-0'])
                    || isset($planets1[6]['phase']['6-1'])
                    || isset($planets2[0]['phase']['0-1'])
                    || isset($planets2[6]['phase']['6-0'])
                    || isset($planets2[6]['phase']['6-1'])
                )
                &&
                (
                    $planets1[0]['in_house_id'] == 10 || $planets1[1]['in_house_id'] == 10
                    || $planets2[0]['in_house_id'] == 10 || $planets2[1]['in_house_id'] == 10
                    || (isset($planets1[0]['phase']['0-' . MC]) && $planets1[0]['phase']['0-' . MC]['phase_e'] == 0)
                    || (isset($planets1[1]['phase']['1-' . MC]) && $planets1[1]['phase']['1-' . MC]['phase_e'] == 0)
                    || (isset($planets2[0]['phase']['0-' . MC]) && $planets2[0]['phase']['0-' . MC]['phase_e'] == 0)
                    || (isset($planets2[1]['phase']['0-' . MC]) && $planets2[1]['phase']['1-' . MC]['phase_e'] == 0)
                )
            )
        )
        {
            if ($housePower[0][10] != 0 || $housePower[1][10] != 0)
            {
                $partner = $housePower[0][10] / ($housePower[0][10] + $housePower[1][10]) * ($attract + $happy) / 150;
                $relations[] = [$partner, '合作伙伴', 'partner'];
                if ($debug) echo "合作伙伴关系概率为:$partner\n";
            }

        }
        // 同事 11宫总能量最大或一方日或月落对方11宫
        $res = [];
        foreach ($housePower[0] as $i => $h0) $res[$i] = $housePower[0][$i] + $housePower[1][$i];
        if (
            array_search(max($res), $res) == 11
            || $planets1[0]['in_house_id'] == 11
            || $planets1[1]['in_house_id'] == 11
            || $planets2[0]['in_house_id'] == 11
            || $planets2[1]['in_house_id'] == 11
            ||
            (
                (
                    isset($planets1[0]['phase']['0-1'])
                    || isset($planets1[6]['phase']['6-0'])
                    || isset($planets1[6]['phase']['6-1'])
                    || isset($planets2[0]['phase']['0-1'])
                    || isset($planets2[6]['phase']['6-0'])
                    || isset($planets2[6]['phase']['6-1'])
                )
                &&
                (
                    $planets1[0]['in_house_id'] == 6 || $planets1[1]['in_house_id'] == 6
                    || $planets2[0]['in_house_id'] == 6 || $planets2[1]['in_house_id'] == 6
                )
            )
        )
        {
//            $worker = $housePower[0][11] / ($housePower[0][11] + $housePower[1][11] + 10);
            $worker = $housePower[0][11] / ($housePower[0][11] + $housePower[1][11] + 20);// edit by guokunsheng 20180124
            $relations[] = [$worker, '同事', 'worker'];
            if ($debug) echo "同事关系概率为:$worker\n";
        }
//        上下级拆分成同事和合作伙伴  20180205
//        存在日月、土日或土月相位，且一方日或月在另一方6宫==同事
//        存在日月、土日或土月相位，且一方日或月在另一方10宫或合天顶==合作伙伴
//        // 上下级 存在日月、土日或土月相位，且一方日或月在另一方6宫或10宫或合中天
//        if(
//            (
//                $planets1[0]['in_house_id'] == 6 || $planets1[1]['in_house_id'] == 6
//                || $planets2[0]['in_house_id'] == 6 || $planets2[1]['in_house_id'] == 6
//                || $planets1[0]['in_house_id'] == 10 || $planets1[1]['in_house_id'] == 10
//                || $planets2[0]['in_house_id'] == 10 || $planets2[1]['in_house_id'] == 10
//                || (isset($planets1[0]['phase']['0-'.MC]) && $planets1[0]['phase']['0-'.MC]['phase_e'] == 0)
//                || (isset($planets1[1]['phase']['1-'.MC]) && $planets1[1]['phase']['1-'.MC]['phase_e'] == 0)
//                || (isset($planets2[0]['phase']['0-'.MC]) && $planets2[0]['phase']['0-'.MC]['phase_e'] == 0)
//                || (isset($planets2[1]['phase']['1-'.MC]) && $planets2[1]['phase']['1-'.MC]['phase_e'] == 0)
//            )
//            &&
//            (
//                isset($planets1[0]['phase']['0-6']) || isset($planets1[1]['phase']['1-6'])
//                || isset($planets2[0]['phase']['0-6']) || isset($planets2[1]['phase']['1-6'])
//            )
//        )
//        {
//            // 6宫建设能量/6宫总能量
////            $boss = ($housePower[0][6]+$housePower[0][10]) /( $housePower[0][6] + $housePower[1][6] + $housePower[0][10] + $housePower[1][10] + 10);
//            $boss = ($housePower[0][6]+$housePower[0][10]) /( $housePower[0][6] + $housePower[1][6] + $housePower[0][10] + $housePower[1][10] + 20);// edit by guokunsheng 20180124
//            // （6宫建设能量+10宫建设能量）*（土星影响+沟通）/（6宫总能量+10宫总能量）（火星影响+100-沟通）
////            $boss = ($housePower[0][6]+$housePower[0][10]) * ($chat + $mainPhase['influ']['c'][6]) / ($housePower[0][6] + $housePower[1][6] + $housePower[0][10] + $housePower[1][10]) / ($mainPhase['influ']['c'][4] + 100 - $chat); // 20180125
//            $relations[] = [$boss,'上下级','boss'];
//            if($debug) echo "上下级关系概率为:$boss\n";
//        }
        $is_family = false;
        // 亲人 一方月亮落对方1宫或4宫或合天底或合上升下降或合南北交或与对方月亮合拱六分
        if (
            in_array($planets1[1]['in_house_id'], [1, 4])
            || (isset($planets1[1]['phase']['1-' . ASC]) && in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
            || (isset($planets1[1]['phase']['1-' . MC]) && $planets1[1]['phase']['1-' . MC]['phase_e'] == 180)
            || (isset($planets1[1]['phase']['1-12']) && in_array($planets1[1]['phase']['1-12']['phase_e'], [0, 180]))
            || in_array($planets2[1]['in_house_id'], [1, 4])
            || (isset($planets2[1]['phase']['1-' . ASC]) && in_array($planets2[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
            || (isset($planets2[1]['phase']['1-' . MC]) && $planets2[1]['phase']['1-' . MC]['phase_e'] == 180)
            || (isset($planets2[1]['phase']['1-12']) && in_array($planets2[1]['phase']['1-12']['phase_e'], [0, 180]))
            || (isset($planets1[1]['phase']['1-1']) && in_array($planets1[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
        )
        {
            $coef1 = $this->getThePrimingScore($data1);
            $coef2 = $this->getThePrimingScore($data2);
            $family = 1;// #######################################
            if ($housePower[0][4] + $housePower[1][4]
                + $coef1['obverse'][1] + $coef2['obverse'][1]
                + $coef1['versa'][1] + $coef2['versa'][1] != 0)
            {
                $family = (($coef1['obverse'][1] + $coef2['obverse'][1]) + $housePower[0][4])
                    / ($housePower[0][4] + $housePower[1][4]
                        + $coef1['obverse'][1] + $coef2['obverse'][1]
                        + $coef1['versa'][1] + $coef2['versa'][1]);
            }

            $family *= ($harmoniousAndConflict[0] / 100);
            $relations[] = [$family, '亲朋好友', 'family'];
            if ($debug) echo "亲朋好友关系概率为:$family\n";
            $is_family = true;
        }
        //若合盘双方相差20岁以上，且存在亲朋好友关系，或缘分大于70  =》 亲朋好友100%
        if ($this->type !== 5 && abs($this->timestamp1 - $this->timestamp2) > 20 * 365 * 86400)
        {
            if ($is_family === true || $probTobeLover > 70)
            {
                $sc = $probTobeLover / 100;
                // 1年长   2年幼
                if ($this->timestamp1 < $this->timestamp2)
                {
                    // 父女
                    if ($this->sex1 == 1 && $this->sex2 == 2)
                    {
                        $relations[] = [$sc, '父女', 'father_daughter'];
                    } // 父子
                    elseif ($this->sex1 == 1 && $this->sex2 == 1)
                    {
                        $relations[] = [$sc, '父子', 'father_son'];
                    } // 母女
                    elseif ($this->sex1 == 2 && $this->sex2 == 2)
                    {
                        $relations[] = [$sc, '母女', 'mother_daughter'];
                    } // 母子
                    elseif ($this->sex1 == 2 && $this->sex2 == 1)
                    {
                        $relations[] = [$sc, '母子', 'mother_daughter'];
                    }
                } // 1年幼    2年长
                elseif ($this->timestamp1 > $this->timestamp2)
                {
                    // 父女
                    if ($this->sex1 == 2 && $this->sex2 == 1)
                    {
                        $relations[] = [$sc, '父女', 'father_daughter'];
                    } // 父子
                    elseif ($this->sex1 == 1 && $this->sex2 == 1)
                    {
                        $relations[] = [$sc, '父子', 'father_son'];
                    } // 母女
                    elseif ($this->sex1 == 2 && $this->sex2 == 2)
                    {
                        $relations[] = [$sc, '母女', 'mother_daughter'];
                    } // 母子
                    elseif ($this->sex1 == 1 && $this->sex2 == 2)
                    {
                        $relations[] = [$sc, '母子', 'mother_daughter'];
                    }
                }
            }
        }
        // 闺蜜 女女 有日金、月金、金金、月月、日月的合拱六分相或金星合升降或月亮合升降
        if ($this->sex1 == 2 && $this->sex2 == 2)
        {
            if (
                (isset($planets1[0]['phase']['0-3']) && in_array($planets1[0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                || (isset($planets1[1]['phase']['1-3']) && in_array($planets1[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                || (isset($planets1[3]['phase']['3-3']) && in_array($planets1[3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                || (isset($planets1[1]['phase']['1-1']) && in_array($planets1[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                || (isset($planets1[0]['phase']['0-1']) && in_array($planets1[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                || (isset($planets2[0]['phase']['0-3']) && in_array($planets2[0]['phase']['0-3']['phase_e'], [0, 60, 120]))
                || (isset($planets2[1]['phase']['1-3']) && in_array($planets2[1]['phase']['1-3']['phase_e'], [0, 60, 120]))
                || (isset($planets2[3]['phase']['3-3']) && in_array($planets2[3]['phase']['3-3']['phase_e'], [0, 60, 120]))
                || (isset($planets2[1]['phase']['1-1']) && in_array($planets2[1]['phase']['1-1']['phase_e'], [0, 60, 120]))
                || (isset($planets2[0]['phase']['0-1']) && in_array($planets2[0]['phase']['0-1']['phase_e'], [0, 60, 120]))
                || (isset($planets1[3]['phase']['3-' . ASC]) && in_array($planets1[3]['phase']['3-' . ASC]['phase_e'], [0, 180]))
                || (isset($planets1[1]['phase']['1-' . ASC]) && in_array($planets1[1]['phase']['1-' . ASC]['phase_e'], [0, 180]))
            )
            {
                // （3正+7正+11正）/（3总+7总+11总）
//                $gf = (
//                        $housePower[0][3]
//                        + $housePower[0][7]
//                        + $housePower[0][11]
//                    )
//                    / (
//                        $housePower[0][3] + $housePower[1][3]
//                        + $housePower[0][7] + $housePower[1][7]
//                        + $housePower[0][11] + $housePower[1][11]
//                    );
                $gf = ($benefit + $harmoniousAndConflict[0]) / 180;

                $relations[] = [$gf, '闺蜜', 'girlfriends'];
                if ($debug) echo "闺蜜关系概率为:$gf\n";
            }
        }

        if (empty($relations))
        {
            $relations[0] = [1, '路人', 'passerby'];
        }
        $temp = [];
        foreach ($relations as $rl)
        {
            $temp[] = [
                'per' => $rl[0],
                'name_cn' => $rl[1],
                'name_en' => $rl[2],
            ];
        }
        return $temp;
    }
}
